Article
Problem:
Multiple backup versions available on your disk.
A complement to ordinary backup/archive.
Solution:
Compress selected dirs and or filetypes into zipfiles and name them with a number last showing the version.
A 1 last means -1 day, a 2 means -2 days and so on. My example script below rotates the names
and make a new 0 version.
The pros with this solution are that you have multiple versions directly available.
So if you have overwritten a document two days ago and by mistake deleted to much text, it's very easy just get it back.
Example:
#!/bin/bash # # Do backups for Tore # echo "Tores backups /etc/cron.custom/tags-backup.sh" BKUPDIR="/home/tore/backups" echo "backupdir="$BKUPDIR # let DAY=$(date -u +%w) # echo "Day="$DAY # Test if backup dir is mounted. if test -d "$BKUPDIR"; then echo "OK backupdir is available" else echo "WARN backup dir not available" fi # Test if backup dir is mounted. if test -d "$BKUPDIR"; then echo "OK backupdir is available, rotating backup zipfiles now." mv --force $BKUPDIR/tag-docs-5.zip $BKUPDIR/tag-docs-6.zip mv --force $BKUPDIR/tag-docs-4.zip $BKUPDIR/tag-docs-5.zip mv --force $BKUPDIR/tag-docs-3.zip $BKUPDIR/tag-docs-4.zip mv --force $BKUPDIR/tag-docs-2.zip $BKUPDIR/tag-docs-3.zip mv --force $BKUPDIR/tag-docs-1.zip $BKUPDIR/tag-docs-2.zip cp --remove-destination $BKUPDIR/tag-docs-0.zip $BKUPDIR/tag-docs-1.zip mv --force $BKUPDIR/tag-html-5.zip $BKUPDIR/tag-html-6.zip mv --force $BKUPDIR/tag-html-4.zip $BKUPDIR/tag-html-5.zip mv --force $BKUPDIR/tag-html-3.zip $BKUPDIR/tag-html-4.zip mv --force $BKUPDIR/tag-html-2.zip $BKUPDIR/tag-html-3.zip mv --force $BKUPDIR/tag-html-1.zip $BKUPDIR/tag-html-2.zip cp --remove-destination $BKUPDIR/tag-html-0.zip $BKUPDIR/tag-html-1.zip mv --force $BKUPDIR/tag-scripts-5.zip $BKUPDIR/tag-scripts-6.zip mv --force $BKUPDIR/tag-scripts-4.zip $BKUPDIR/tag-scripts-5.zip mv --force $BKUPDIR/tag-scripts-3.zip $BKUPDIR/tag-scripts-4.zip mv --force $BKUPDIR/tag-scripts-2.zip $BKUPDIR/tag-scripts-3.zip mv --force $BKUPDIR/tag-scripts-1.zip $BKUPDIR/tag-scripts-2.zip cp --remove-destination $BKUPDIR/tag-scripts-0.zip $BKUPDIR/tag-scripts-1.zip mv --force $BKUPDIR/tag-gimp-xcf-5.zip $BKUPDIR/tag-gimp-xcf-6.zip mv --force $BKUPDIR/tag-gimp-xcf-4.zip $BKUPDIR/tag-gimp-xcf-5.zip mv --force $BKUPDIR/tag-gimp-xcf-3.zip $BKUPDIR/tag-gimp-xcf-4.zip mv --force $BKUPDIR/tag-gimp-xcf-2.zip $BKUPDIR/tag-gimp-xcf-3.zip mv --force $BKUPDIR/tag-gimp-xcf-1.zip $BKUPDIR/tag-gimp-xcf-2.zip cp --remove-destination $BKUPDIR/tag-gimp-xcf-0.zip $BKUPDIR/tag-gimp-xcf-1.zip mv --force $BKUPDIR/tag-java-5.zip $BKUPDIR/tag-java-6.zip mv --force $BKUPDIR/tag-java-4.zip $BKUPDIR/tag-java-5.zip mv --force $BKUPDIR/tag-java-3.zip $BKUPDIR/tag-java-4.zip mv --force $BKUPDIR/tag-java-2.zip $BKUPDIR/tag-java-3.zip mv --force $BKUPDIR/tag-java-1.zip $BKUPDIR/tag-java-2.zip cp --remove-destination $BKUPDIR/tag-java-0.zip $BKUPDIR/tag-java-1.zip echo "Backup rotate finished, start backing up into zip files" find -L /home/tore/Documents -name "*.txt" -print | zip -u $BKUPDIR/tag-docs-0.zip -@ find -L /home/tore/Documents -name "*.doc" -print | zip -u $BKUPDIR/tag-docs-0.zip -@ find -L /home/tore/Documents -name "*.dvi" -print | zip -u $BKUPDIR/tag-docs-0.zip -@ find -L /home/tore/Documents -name "*.xls" -print | zip -u $BKUPDIR/tag-docs-0.zip -@ find -L /home/tore/Documents -name "*.sdw" -print | zip -u $BKUPDIR/tag-docs-0.zip -@ find -L /home/tore/Documents -name "*.sxw" -print | zip -u $BKUPDIR/tag-docs-0.zip -@ find -L /home/tore/Documents -name "*.rtf" -print | zip -u $BKUPDIR/tag-docs-0.zip -@ find -L /home/tore/Documents -name "*.htm" -print | zip -u $BKUPDIR/tag-html-0.zip -@ find -L /home/tore/Documents -name "*.html" -print | zip -u $BKUPDIR/tag-html-0.zip -@ find -L /home/tore/Documents -name "*.css*" -print | zip -u $BKUPDIR/tag-html-0.zip -@ find -L /home/tore/scripts -name "*" -print | zip -u $BKUPDIR/tag-scripts-0.zip -@ find -L /home/tore/myjava -name "*.java" -print | zip -u $BKUPDIR/tag-java-0.zip -@ find -L /home/tore/pictures -name "*.xcf" -print | zip -u $BKUPDIR/tag-gimp-xcf-0.zip -@ else echo "WARN backup dir not available, no backup will be done" fi
Environment:
Probably any Linux system.
Disclaimer: As with everything else at Cool Solutions, this content is definitely not supported by Novell (so don't even think of calling Support if you try something and it blows up).
It was contributed by a community member and is published "as is." It seems to have worked for at least one person, and might work for you. But please be sure to test, test, test before you do anything drastic with it.
Related Articles
User Comments
- Be the first to comment! To leave a comment you need to Login or Register
- 2131 reads


0