I would like to have a script that periodically and automatically backs up select system files to my NAS, which I have in my fstab to cifs mounts on boot. Based on the responses from Which Folders To Include In backup?, I put together the following script to backup to a "System Files" folder on my NAS:
#!/bin/bash sudo rsync -aAXv --progress --delete /etc /NAS/System\ Files/ sudo rsync -aAXv --progress --delete /opt /NAS/System\ Files/ sudo rsync -aAXv --progress --delete /root /NAS/System\ Files/ sudo rsync -aAXv --progress --delete /snap /NAS/System\ Files/ sudo rsync -aAXv --progress --delete /usr/local /NAS/System\ Files/usr/ sudo rsync -aAXv --progress --delete /var /NAS/System\ Files/
Once I work out the bugs, I intend to set up a cron job to schedule this.
After testing just the /etc line of this code, I noticed there are numerous permissions errors such as:
rsync: symlink "/NAS/System Files/etc/rc0.d/K01bluetooth" -> "../init.d/bluetooth" failed: Permission denied (13)
In this answer, the user states that "Backing them (some files in root) up would be meaningless or they might be even harmful."
Is there a safe way to accomplish this without any errors or without harming my system? Any help is greatly appreciated.
FYI, I am aware that I can create a disk image using a program like Clonezilla, but I would prefer to use a solution that doesn't have to be manually maintained. Also, not sure if Timeshift would do what I'm trying to do, but since I'm running ZFS on root, Timeshift gave me the "device not found" error, since ZFS is not currently supported (as of Timeshift 20.03).
I already have my applications, repos, and keys backing up to my home folder using Apt-Clone, and Duplicity set to backup my home folder to my NAS.
How can I set up incremental backups to include my themes and customisation on Ubuntu 18.04?
How to backup settings and list of installed packages
What is the easiest NAS setup to back up an Ubuntu machine?