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.

Jellyfin HDHomeRun EPG Puller

If you are using Jellyfin on Linux, have a HDHomeRun cable tuner, AND have paid for the DVR feature – you may be wondering “Do I really have to pay for a separate EPG service in Jellyfin?!?!”

Answer is: NO – You can use the EPG data that you paid for with HDHomeRun

I have created a small script that will query HDHomeRun network cable tuner’s key, and use that key to download a EPG compatible with Kodi 🙂

You can make a file called pullhdhomerunxmltv.sh and put the following in it:

#!/bin/bash
echo 'Getting Current Key from HDHomeRun...'
KEY=$(curl http://192.168.10.2/discover.json | jq -r .DeviceAuth)
echo 'Current Key is' $KEY #optional line
echo 'Downloading TV Guide Data...'
curl --compressed https://api.hdhomerun.com/api/xmltv?DeviceAuth=$KEY > /data/Containers/jellyfin/xmltvlist.xml
echo 'Done!'

As you can see…This script is pretty simple. For most, no need for me to explain what it’s doing once you see it. However, to make it easy for everyone – I will explain a few things you must modify to make it suit your needs:

  1. Change 192.168.10.2 to the IP of YOUR HDHomeRun device.
  2. Change /data/Containers/jellyfin/xmltvlist.xml to save the epg file where YOU want it.
  3. Don’t forget to give execute permissions to the script:
chmod +x pullhdhomerunxmltv.sh

If this is not working – please make sure you have DVR service active on your HDHomeRun tuner. EPG is part of that service (gotta know when a show plays to automatically record it!).

Hope this helps some of you Jellyfin users out. I prefer watching TV with Kodi…but if you have to stream it to your phone or remotely – It comes in handy having it in Jellyfin too!

UPDATE: 2/25/2022 – The 2nd curl command appears to now require https:// being included. I’ve updated the code above. If you using it already, you’ll have to modify your script. If you are setting it up new for the first time – just copy and current script as it’s updated and should be good to go!

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!