Simple Backup using Rsync with Synology NAS

I was doing some research for a backup solution for my Fedora 39 Linux Server. I was expecting to use the “Active Backup for Business” software that Synology has. It’s quite easy to setup an agent on Windows and Mac…but not as easy for Linux. Sure, if you are one of those people that have an old version of Linux – it’s not going to be really painful for you (Good luck with updates & security eventually though!). However, if you are on Fedora’s latest versions…it’s not supported!

GREAT! I was hoping maybe I can jimmy it on there, but a brief Google search found many people complaining about the same thing and no hope in site for Synology to update their software. It just doesn’t support the 6.x kernel, so I wasn’t going to spend time trying to force it. Not a backup solution of all things. SO, here began my research in to many options available for Linux backup options.

There are many options out there, but I settled on rsync because of my basic needs. I’ve read arguments regarding duplicity, compression, encryption, and data stability for multiple solutions. Rsync can do a LOT of things that I didn’t realize at first…after all it’s just a “remote sync” tool right? Throw in a Synology in to the mix, and people have had mixed results with backups going to these devices depending on how their setups were configured.

Some options made full images of the system, but those took a lot of space (which I don’t have tons of to waste of massive backups), and time (like Clonezilla and similar ‘full backup’ options). I looked a Veeam, Borg, Restic, BackupPC, TimeShift, BackinTime, and even Bacula…just to name a few. However, many of these required a server/agent client setup and quite a bit of learning (some more than others)…didn’t support Fedora 39, or something else that didn’t quite sell me on it 100%. Now…these are great software solutions for people that need all these features…but all I need here is ONE linux server backed up.

It was difficult to find one that fit my specific (and what I thought) basic needs:

  • Synology Support (Easy, not hackery via SSH – Also reliability of course)
  • If not Synology Support, Easy management system via ISO distribution or linux installation (bare metal install or docker).
  • Web GUI required (though simple command line/config will do I suppose – This is a headless install, so GUI is not preferred).
  • Data backups
  • Easy!!! (I don’t want to spend a lot of time learning a massive solution – I have basic needs).

Long story short – I ended up going with rsync because Synology has a rsync server that I enabled, and easily setup a user. It has a NetBackup folder it automatically creates, so I made sure this user had access to this folder. The rest is done via a simple Bash Script I wrote that runs database backups and then syncs files within my desired folders to the Synology.

Make a file called backup.sh

#!/bin/bash
echo 'Starting Backup...'
echo ''
echo 'Creating Database Backups...'
echo ''
echo 'Dumping WoW DB..'
/root/wowdbbackup/wowbackup.sh
echo 'Dumping XWiki DB..'
/root/xwikidbbackup/xwikibackup.sh
echo 'Done Dumping Databases'
echo ''
echo 'Backing Up Files...'
echo ''
echo 'Backing up /root'
rsync -av --no-o --no-g --no-perms --checksum --password-file=/home/backup/rsync_password /root nasuser@192.168.1.100::NetBackup/My_Backup/
echo 'Backing up /home'
rsync -av --no-o --no-g --no-perms --checksum --password-file=/home/backup/rsync_password /home nasuser@192.168.1.100::NetBackup/My_Backup/
echo 'Backing up Docker Volumes'
rsync -av --no-o --no-g --no-perms --checksum --password-file=/home/backup/rsync_password /var/lib/docker/volumes nasuser@192.168.1.100::NetBackup/My_Backup/
echo 'Backing up Data Folder'
rsync -av --no-o --no-g --no-perms --checksum --password-file=/home/backup/rsync_password /Data nasuser@192.168.1.100::NetBackup/My_Backup/
echo 'Backing up BitWarden'
rsync -av --no-o --no-g --no-perms --checksum --password-file=/home/backup/rsync_password /opt/bitwarden nasuser@192.168.1.100::NetBackup/My_Backup/
echo 'Backing up WebSites'
rsync -av --no-o --no-g --no-perms --checksum --password-file=/home/backup/rsync_password /var/www nasuser@192.168.1.100::NetBackup/My_Backup/
echo 'Backing up Nginx Site Configs'
rsync -av --no-o --no-g --no-perms --checksum --password-file=/home/backup/rsync_password /etc/nginx/sites-available nasuser@192.168.1.100::NetBackup/My_Backup/
echo ''
echo 'Done!'

It creates database backups first via separate scripts. These place the files in /root which is backed up.

–password-file is where you simply create a text file that has the password in there (chmod 600 that file).

Use your user instead of nasuser and your Synology IP instead of 192.168.1.100.
Use your backup source and destination paths as well.

Don’t forget to give it execute permissions: chmod +x backup.sh

Now you can run it and test to make sure it’s creating the files. If it is looking good, make a crontab entry to run it as often as you’d like. Mine runs daily at 3AM for example:

(You can enter crontab by typing: crontab -e)

0 3 * * * /home/backup/backup.sh

Save it (if using vi, it’s :wq!)

You should be all set! Of course, you should make sure the crontab is working by verifying daily backups appear for your databases and other files.

If you want an example database backup script (You need to set your own IP and credentials), here is what I use:

databasebackup.sh

#!/bin/bash
echo 'Backing up WoW...'
echo 'Backing up Auth DB..'
mysqldump -h 127.0.0.1 -P3306 -uroot -ppassword acore_auth > acore_auth-$(date +%F).sql
echo 'Done'
echo 'Backing up Characters DB..'
mysqldump -h 127.0.0.1 -P3306 -uroot -ppassword acore_characters > acore_characters-$(date +%F).sql
echo 'Done'
echo 'Backing up World DB..'
mysqldump -h 127.0.0.1 -P3306 -uroot -ppassword acore_world > acore_world-$(date +%F).sql
chmod 600 acore*.sql
echo 'Cleaning up old backups..'
find /root/wowdbbackup -type f -iname '*.sql' -mtime +10 -delete
echo 'Done making all backups!'

This dumps the selected databases in to a file with the date tagged in the filename.
It also changes the file permissions to ensure all .sql files in that folder have been set with chmod 600
It looks for .sql files in the folder that are older than 10 days, and deletes them. MAKE SURE YOU READ THIS AND UNDERSTAND IT WILL DELETE ANY SQL FILES OLDER THAN 10 DAYS IN THE SPECIFIED FOLDER.

Hope this helps anyone else looking for a ‘simple’ backup solution for a Linux Server to a Synology NAS. The best thing is this can work with any Linux/Nix OS that has rsync! No need to worry about “will this work on my Linux?!”.

Are there better backup solutions or ways to do this? Probably…but this works for me – and hopefully it can work for you too!

Lastly – Shame on you Synology for the poor Linux support in Active Backup for Business.

How to fix broken install button phpBB 3.2 with Nginx

It looks phpBB 3.2 is no longer super friendly with Nginx unless you put a specific entry in your server block…And by not super friendly…I mean you can’t even install the damn thing anymore with a standard server block configuration!

However, All you have to do is add this after one of the locations in there:

        location /install/app.php {
                 try_files $uri $uri/ /install/app.php?$query_string;
        }

This took me a while to find, so hopefully it helps you! After adding this, I finally was able to get the Installation to appear after clicking the “Install” tab 🙂

Found it here:

https://www.phpbb.com/community/viewtopic.php?t=2405881

Thanks battye!

Windows and Linux together?

Yep…It’s true. Microsoft and Ubuntu have teamed up to make a Bash prompt for Windows 10 (64-bit).

Check it out:

https://github.com/Microsoft/BashOnWindows

You have to be on the right version of Windows (Dubbed “Anniversary Edition”) to install Bash.

Non MSDN and Enterprise editions can easily upgrade now to the desired version. They will either get the update automatically (or you can check for updates). It’s rolling out, so if you don’t have it yet, you can get it manually from here:

https://support.microsoft.com/en-us/help/12387/windows-10-update-history

MSDN and Enterprise editions must download the new ISO, and do a Windows update in order to upgrade to the required version that can install Bash. I thought that sucked…but whatever. You’ll need Enterprise Build 14393.

If you’re on the right version, you can get updates and find the “Windows Linux Subsystem” under Add/Remove Windows Features.

What to expect? A Beta…some stuff works but core functions are still being developed. the command “ifconfig” doesn’t work yet, and some devices aren’t being detected quite well (as simple as I can put it).

If you run in to issues running ping, dig, curl, etc – Run BASH as an Administrator. That solves a lot of errors.

I’ve also heard Bitdefender, and other firewalls, can cause lots of issues with Bash. Disable them and test. AVG even seems to have a spot specifically for Bash somewhere in the advanced settings.

Happy Windows BASHing ;D

Want to buy Windows 10 Pro or Home (64-bit links provided)? Please consider purchasing from these links (It helps support this site and does not cost you anything additional!)

(Originally Posted August 23, 2016)