I finally got a NAS (Synology DS216se) for the house to keep our photos and other important files safe. I was starting to get really nervous about losing data both on the home computer and this server as well. The new NAS required a good backup strategy. I really wanted to follow the 3-2-1 strategy: 3 locations, 2 different devices/media, 1 offsite location. This post is about backing up to my second location. I plan to sync my NAS data to Amazon glacier in the near future to fulfill my offsite requirement.

Home Computer

To backup the home computer I am using the native Windows backup utility to backup critical data to a second hard drive. This is for easy restoral in case of catastrophic loss of my OS and primary drive.

I am also using the Synology Cloud Station Backup client to sync some other files directly to the NAS. This is mostly for photos.

Phones

Using the DS Files app for Android, I am able to sync photos from our phones directly to the NAS whenever we get home and connect to the home WiFi.

Server

For my three apps on the server I backup each one individually.

Confluence

Confluence has a built in backup feature that can be configured directly in the application and drops the backup files right to disk as tar.gz files. I had a little difficulty figuring out the cron syntax to schedule the job. I finally figured out what I needed to create the backup once a week at 2 AM.

0 0 2 ? * 2

Ghost

Ghost does not have as simply of a backup utility. They normally recommend backing up the content directory which has all the uploaded images and theme files. The rest of the data is written to the MySQL database, more on that later.

To backup the content directory I just made a cron job to archive and compress the data.

10 2    * * 2   root    tar -zcvf /var/backups/ghost/ghost_backup_`date +%Y-%m-%d`.tar.gz /var/www/ghost/content/ /var/www/ghost/config.production.json

MySQL

To backup the databases for both Ghost and Confluence I just used the mysqldump utility and then zip up the contents to save some space.

mysqldump -u mysql_user -pnotmyrealpassword --all-databases | gzip -9 > /var/backups/mysql/mysqldump_`date +%m-%d-%Y`.sql.gz

NAS

The phones and computer were easy to get to the NAS due to the native apps. There looked like there as a native app for server backups, Active Backup, but I could not find the app in the Synology Package Manager.

The alternative was to use rsync to transfer the files from the server to the NAS. I followed this guide which boiled down to some fairly simple steps.

  • Enable SFTP and SSH on the NAS
  • SSH into the NAS, generate an SSH key, and put the public key in the authorized_keys file on the server
  • Create a script on the NAS to carry out the rsync jobs
  • Schedule that script to run through the Synology web interface.
rsync --delete --stats -zav -e "ssh -p 12345" [email protected]:/var/backups/mysql /volume1/homes/trevor/ghost-backup/mysql
rsync --delete --stats -zav -e "ssh -p 12345" [email protected]:/var/backups/ghost /volume1/homes/trevor/ghost-backup/ghost
rsync --delete --stats -zav -e "ssh -p 12345" [email protected]:/var/atlassian/application-data/confluence/backups /volume1/homes/trevor/ghost-backup/confluence

Glacier

The last step will be the enable Amazon Glacier for my offsite backup of the NAS. I still need to do my research on that to ensure that I don't end up spending my life savings on storage.