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.