Skip to content

Instantly share code, notes, and snippets.

@cmbaughman
Created June 10, 2014 17:13
Show Gist options
  • Save cmbaughman/75e01e697b5d07fd2324 to your computer and use it in GitHub Desktop.
Save cmbaughman/75e01e697b5d07fd2324 to your computer and use it in GitHub Desktop.
How to use rsync from your local machine to AWS S3
#!/bin/bash
# Dependencies
install build-essential libcurl4-openssl-dev libxml2-dev libfuse-dev
# Compile s3fs from source
wget https://s3fs.googlecode.com/files/s3fs-1.74.tar.gz
tar -zxvf s3fs-1.74.tar.gz
cd s3fs-1.74
./configure
make
sudo make install # outputs in /usr/local/bin/s3fs
sudo mkdir /mnt/s3
chown username.username /mnt/s3
# Create a ~/.passwd-s3fs file
echo "s3Bucket:youracessKey:secretKey" > ~/.passwd-s3fs
chmod 600 ~/.passwd-s3fs
# make a script like this and give it (chmod 700 yourScript.sh):
# /usr/bin/s3fs yourbucket /mnt/s3 -ouse_cache=/tmp
# /usr/bin/rsync -avz --delete /home/username/dir/you/want/to/backup /mnt/s3
# /bin/umount /mnt/s3
# Make that sucka a cron job!
sudo su
crontab -e
0 0 * * * /path/to/yourScript.sh # this runs it everyday at midnight
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment