Downloads auf Deutsch
Downloads auf Deutsch

Downloads

Here is a set of scripts for my backup solution.

Please note that this is not a complete, worry-free solution! I am describing my personal backup procedure here and providing the scripts as I use them.

I've tried to catch as many bugs as possible and make the whole thing as safe as possible. However, I can't guarantee that it will work on every system and under all circumstances. It may also contain untested or unstable features.

Do not use the scripts if you do not at least have a basic understanding of what they do and why they are the way they are.

Please note that for some scripts you may need to make changes to path specifications, usernames, or password settings.

Here all together in one zip file: backup.zip

Main Scripts

These two scripts are the only ones that are normally called directly.

backup.pl

The script backup.pl backs up the SSD on the NAS disk.

For this to work, there must be a Backups directory on the NAS, in which the script, if it doesn't already exist, creates a directory with the system's hostname. The entire SSD backup is then placed there.

This does not yet offer protection against serious disruptions (fire, theft, virus, whatever you want) as the NAS disk would be lost along with the SSD.

It only helps against accidental deletion or other stupid mistakes on the SSD, as you could then quickly and easily restore the data from the NAS drive.

However, it simplifies the subsequent backup to external hard drives, because it is then sufficient to back up the NAS drive.

rsyncNas2Backup

The script rsyncNas2Backup backs up the contents of the NAS drive to an external backup drive.

Every directory of the NAS root that is to be backed up must already exist on the backup disk, otherwise it will be skipped.

This is changed regularly, so that several disks of different ages exist that are not online and available for restoration.

Database Scripts

Please note that you will need to adjust your database name, username, and password in the following scripts!

backupUpdateDB

The script backupUpdateDB enters every successful backup of every share into the database.

backupUpdateMedia

The script backupUpdateMedia is called by rsyncNas2Backup and updates the data on the external backup disk.

This script can also be called directly.

Without parameters (as is also the case with rsyncNas2Backup), it only updates the data on the backup disk. This disk must be mounted for this to work.

The commandline option -d /dev/<device> updates all partitions on this disk.

The -a option updates all partitions of all available disks.

The mediaName is the filesystem label of the respective partition, which you can set with e2label.

Helper Scripts

The perl module backupCred.pm is required in some scripts and defines constants such as the NAS UUID or access data for the database.

The script rsyncEnc.pl is responsible for backing up the encrypted partition.

It is called by and dependent on rsyncNas2Backup. It cannot be called directly from the console! If you do not have an encrypted partition, you can simply remove or comment out its call in rsyncNas2Backup.

SQL

An SQL-Skript script to create the tables and some views.

You still need to replace all users named robert with your desired, already existing username.

Since the username and password are unencrypted in the scripts (which should therefore be mod 0700), it is advisable to create a user (see backupCred.pm) who only has Read, Update and Insert rights to these tables.


I have created the procedure and scripts with great care, but I cannot guarantee that they will work as expected on all systems and under all circumstances. I cannot be held liable for any data loss resulting from their use. If you use these scripts, you do so at your own risk.