Skip to content

Instantly share code, notes, and snippets.

@jonbalbarin
Created June 30, 2014 12:26
Show Gist options
  • Save jonbalbarin/05f421fb93fa372e2654 to your computer and use it in GitHub Desktop.
Save jonbalbarin/05f421fb93fa372e2654 to your computer and use it in GitHub Desktop.
compress current directory and move it to a backups folder in dropbox
#!/bin/bash
BASE_PATH=/tmp/$(basename $(pwd))_$(date "+%Y-%m-%d-%H%M%S")
if [ -z "$1" ]; then
BACKUP_ARCHIVE=$BASE_PATH.tar.gz
else
BACKUP_ARCHIVE="$BASE_PATH"_\(${1// /-}\).tar.gz
fi
echo "backing up to "$BACKUP_ARCHIVE
tar -czf $BACKUP_ARCHIVE .
mkdir -p ~/Dropbox/Backup
cp -pv $BACKUP_ARCHIVE ~/Dropbox/Backup
rm $BACKUP_ARCHIVE
echo done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment