Showing posts with label script. Show all posts
Showing posts with label script. Show all posts

Thursday, 30 May 2013

bash script to timestamp snapshot backups of directory

modified a script from 
http://aaronparecki.com/articles/2010/07/09/1/how-to-back-up-dropbox-automatically-daily-weekly-monthly-snapshots

to be a simplified snapshot copy of the FOLDER and append the date to the folder name. Useful to have an backup on Dropbox since some files might go missing suddenly on shared folders.

#!/bin/bash
#eg.
#sh snapshot.sh FOLDER [go]
# 'go' will execute
path=Snaphotbackup-`date +%m-%b-%y`
# Run with "go" as the second CLI parameter to actually run the rsync command, otherwise prints the command that would have been run (useful for testing)
if [[ "$2" == "go" ]]
then
        rsync -avP --delete $1 $1-$path
else
        echo rsync -avP --delete $1 $1-$path
fi

Datanami, Woe be me