be aware that rsync is a sync tool - if you have an important file and then you do echo "" > important.txt
you end up with an empty file that gets synced to your backup.
That's written a little bit unclear: rsync doesn't blank your backup file untile you say "sync this file" - there is no automatic sync. And a sync is exact what most users want a backup to do: Please update my backup, so it is equal to waht I have on my harddrive. Also rsync knows some params with which you could avoid blanked files from being transfered. But: Overwriting a fine backup with accidental damaged files can happen. That's why I'm using svn for some software development even when I'm the only deveoper (rollback), two separated backup hardware and no automatic execution of a backup run.
Actually, there is no general recommendation for a backup, the scenarios are quite too different - even in this case for a "home user": A backup is more than a piece of software, it is a concept. But the following has proven more than once itself, and may be usefull for someone else here…:
1) Backup the package list:
pkg info > packages_all.txt
pkg query -e '%a = 0' %o > packages_base.txt
pkg_cutleaves -l > packages_nodeps.txt
The first contains all installed packages, the second contains those I have explicitly installed, and the third one contains only those packages that are not referenced by any other package; If I need to reinstall my computer I only need to reinstall the packages on the last list - and be done. The other two lists are more for control purposes. To use "pkg_cutleaves" you need to install it first.
2) Backup the system configuration:
tar cf - /etc/ | gzip -f9 > etc.tar.gz
tar cf - /usr/local/etc/ | gzip -f9 > usr_local_etc.tar.gz
For this you need root privileges; I recommend using tools like doas, super or sudo, so you can do such backups as user.
3) Backup databases:
If you are using databases like PostgreSQL, Mariadb etc. make a dump of each database. It makes sense to compress such a dump with "gzip" afterwards.
4) Backup user data:
"rsync" is the tool of choice for me. First I recommend to create a exclude file - because temporary and caching stuff will be automatically rebuilt, and thus it does not need to be backuped; Here is a little from my exclude file:
Code:
.cache/
cache/
Cache/
application_cache/
opcache/
.dbus
.fontconfig/
.fullcircle/
.thumbnails/
tmp/
lost+found/
.snap/
Downloads/
A typical rsync call to backup a users home would be:
rsync -avz --exclude-from=/path/to/excludefile --delete --safe-links /home/whoever/ /path/to/target/
I myself use the parameters "-rtDv" instead of "-avz"; A little reading in the man page of rsync does no harm if you want to use it
Also the tool "nice" deservs a mention here, which can lower the priority of such a backup command (so my computers runs as fast as ever while doing backups).
And at least: Everything can be packed together into a small shell script, and your ready. Very important: At the beginning always check your backups, later still check them every now and then. And do not forget to check the file permissions in the backup.
However, when using USB drives the file permissions are lost to the "classic home user" (and often causes error messages during the backup); In my opinion a NAS which can handle SSH or NFS (and not only Samba) is preferable (build your own, and you win full control over its operating system, and maybe you can do this without a fan). If you do such a backup regularly it runs quite fast; And it doesn't matter that a cheap NAS doesn't process 100MB/sec, or that the WLAN is slower than the USB cable. Otherwise you have to reformat the USB drive so that it is able to understand things like "rw-r--r--".
"GUI" was also asked: I once wrote a small tool for myself to do backups, with which my surrounding is also happy - and it is of course able to handle the above stuff completely:
www.jmos.net
Called with the parameter "-d" it can also remind you if you have not made a backup for a longer time (configurable). But actually I should rework this tool…