How to Upgrade Sendy from Version 5 to 6 from the Shell via SSH

I’m using Sendy for our newsletters. Recently, verison 6 was released. Here’s how I updated like a pro on my VPS via SSH.

The beginner-friendly but ultimately drag-and-drop/FTP-based online instructions assume that you will be moving files over from “new location” to “existing location”. That’s quite cumbersome when all you have is SSH.

Here’s how I translated the steps to the shell to merge the v6 files into your v5 installation.

Note: I assume Sendy is installed in the ~/sendy.mydomain.com/ directoy, on the mydomain.com server. Replace this with your actual settings, of course!

Prepare the files on the host

You can prepare the host whichever way you like, as long as the result is an unzipped v6 directory and your old v5 installation on the host machine.

Here’re instructions assuming ~/sendy.mydomain.com/ on the host is the existing v5 installation, and ~/sendy/ will be the unzipped v6.

  1. Download the latest Sendy version locally using your license key: https://sendy.co/get-updated – I didn’t find a way to bypass browser-based download. So no wget download to the server this time.
  2. Copy the .zip to your host via scp, e.g. using:

     me@local:~/Downloads $ scp sendy-6.0.1.1.zip user@mydomain.com:~/
    
  3. ssh onto the host machine:

     me@local:~/Downloads $ ssh user@mydomain.com
    
  4. Backup your current install into an archive (replace paths as needed):

    admin@server:~/ $ tar -czf sendy-bak.tar.bz2 sendy.mydomain.com/
    
  5. Finally unzip Sendy into a new directory:

     admin@server:~/ $ unzip sendy-6.0.1.1.zip
     ...
    
     # This is what we'll be working with:
     admin@server:~/ $ ls
     sendy
     sendy-6.0.1.1.zip
     sendy.mydomain.com
    

    The sendy-6.x.x.zip file will unzip into sendy/ by default: so make sure you don’t run into directory name conflicts or change the destination.

Perform the upgrade from the terminal

Now perform all the update instruction steps, but from the shell. One by one:

# Copy existing .htaccess file
admin@server:~/ $ cp sendy.mydomain.com/.htaccess sendy/

# Copy existing config file
admin@server:~/ $ cp sendy.mydomain.com/includes/config.php sendy/includes/config.php

# Merge v6 into v5 (AFTER THE BACKUP, SEE STEP 4 ABOVE)
admin@server:~/ $ rsync -ar --progress sendy/ sendy.mydomain.com/

Note we skipped two steps:

  • Transfering language files, because we’ll be merging the new installation’s locale/ directory with the existing one;
  • Removal of the uploads/ subdirectory, because rsync’s merging does not remove files in directories – with these options at least.

rsync does a lot of things the DWIM (Do What I Mean) way by default. Drag-and-drop copying of new files over existing ones can – depending on your OS! – replace contentful directories with empty ones, or merge them, or skip empty source directories.

We did have to preserve two important files, though: .htaccess and includes/config.php. That’s why we need to either remove them from the source (the v6 folder) or overwrite them. That’s a two-way merge, so to speak, where we merge setting changes into the freshly unzipped folder, then copy everything over into the old location

If want to do a two-way merge on existing the language files and uploads, too, excluding English language files as the docs instruct, use:

# Transfer existing uploads
admin@server:~/ $ rsync -ar --progress ~/sendy.mydomain.com/uploads/ sendy/uploads/

# Keep custom language files, except en_US, which Sendy ships with
admin@server:~/ $ rsync -ar --exclude "en_US/" --progress ~/sendy.mydomain.com/locale/ sendy/locale/

But that’s not necessary. And depending on your amount of uploads creates waste by duplicting the files.

As always, if you want to verify what would happen (to check if skipping English really worked), add the --dry-run flag, e.g. before --progress.

Troubleshooting

If you botched up the copy process, remove the broken install and unarchive your backup (YOU DID MAKE THE BACKUP, RIGHT?):

# Remove broken install (not rm'ing, just moving away)
admin@server:~/ $ mv sendy.mydomain.com{,_broken}

# Unarchive into ~/sendy.mydomain.com
admin@server:~/ $ ls
sendy               # The extracted v6
sendy-bak.tar.bz2   # The backup archive
sendy.mydomain.com_broken

admin@server:~/ $ tar -xzf sendy-bak.tar.bz2

admin@server:~/ $ ls
sendy-v6.0
sendy               # The extracted v6
sendy-bak.tar.bz2   # The backup archive
sendy.mydomain.com  # NEW: The restored backup
sendy.mydomain.com_broken

Cleanup

If everything works, download the backup to your machine …

# On your computer:
me@local:~/Downloads $ scp user@mydomain.com:~/sendy-bak.tar.bz2 \
      2022-04-26_sendy-backup.tar.bz2

…, remove it from the host, and remove the unzipped v6 files and the download:

admin@server:~/ $ rm -rf sendy-6.0.1.1.zip sendy/ sendy-bak.tar-bz2

Finished.

Receive new .