Small TAR Backup script

While I am still working on my tergum project, a fully functional backup software written in #JAVA I am still far away from completing but last night I required to role back some development files a few days old and while I do have a backup it’s just a daily rsync of my filesystems so I could not choose a older version of my files only the most recent backup.

There for I quickly wrote a new script that will keep multiple version of my backups using “TAR” but also ability to increment the backups and I can go back days.

It’s very simple to use, configure and run, so here is what you need to know:

1) Save the script somewhere on your system and make it executable:
$ chmod 755 smalltarbkp.bash

2) Update the following VARIABLES in the script
#################################################
# UPDATE VARIABLES #
#################################################
SIZE=”200″ # Split tar file $SIZE in MEGABYTES
SVR=”/pi-backups” # NFS mount on Backup server

3) Manual run the script with or without verbose, example:

What the entire command means:
# smalltarbkp.bash –> Actual script
# -path –> FLAG
# /home/ricardo/scripts –> PATH to backup
# -name –> FLAG
# “Scripts” –> Name of the directory or whatever allows you to remember what you backed up in the tar file (NO_SPCACES, NOT BLANC)
# -verbose –> Optional as it will show the files backing up at the time or NOT

Example:
$ /smalltarbkp.bash -path /home/ricardo/scripts -name “Scripts”
$ /smalltarbkp.bash -path /home/ricardo/scripts -name “Scripts” -verbose

4) Configure in cron to run when you want automatically
$ crontab -e
### This will run every day at 05AM
0 5 * * * /home/ricardo/scripts/smalltarbkp.bash -path /home/ricardo/scripts -name “Scripts” >/dev/null 2>&1

Quick image to show it:

I hope you find this useful, fell free to download and modify it / improve it and if you like please share the improvements.

Download




Leave a Reply