Skip to content

Instantly share code, notes, and snippets.

@datawookie
Last active January 16, 2019 02:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save datawookie/cec952f6350c269c724ef35b361d67bc to your computer and use it in GitHub Desktop.
Save datawookie/cec952f6350c269c724ef35b361d67bc to your computer and use it in GitHub Desktop.
Compress file and copy to S3
#!/bin/bash
# $ s3-backup data-file.txt s3://my-backup-folder
#
# Install under /usr/bin/ if it will be run from cron.
FILEPATH=$1
FILENAME=`basename $FILEPATH`
FILEDATE=`date +%Y%m%d-%H%M`-$FILENAME
bzip2 -c $FILEPATH >$FILEDATE.bz2
s3cmd put $FILEDATE.bz2 $2
rm $FILEDATE.bz2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment