Skip to content

Instantly share code, notes, and snippets.

@yashodhank
Forked from bitkidd/aws-vesta-s3.md
Created August 4, 2016 05:26
Show Gist options
  • Save yashodhank/022d51c41a63a3b4806d1264001add4a to your computer and use it in GitHub Desktop.
Save yashodhank/022d51c41a63a3b4806d1264001add4a to your computer and use it in GitHub Desktop.
AWS S3 backup for Vesta

Before doing all this you have to create a bucket in your AWS console. Or just use AWS cli tool in order to create one.

  • Install pip (if not installed already):
$ curl -O https://bootstrap.pypa.io/get-pip.py
  • Install AWS cli tool:
$ sudo pip install awscli
  • Configure AWS cli tool:
$ aws configure
AWS Access Key ID [None]: <YOUR_AWESOME_KEY>
AWS Secret Access Key [None]: <YOUR_AWESOME_KEY>
Default region name [None]: us-west-2
Default output format [None]: json
  • Backup old file, then open and edit Vesta command v-backup-user:
$ cp /usr/local/vesta/bin/v-backup-user /usr/local/vesta/bin/v-backup-user_backup
$ sudo nano /usr/local/vesta/bin/v-backup-user
  • Somewhere in Variable&Function section add:
# AWS arguments
bucket=s3://<your_awesome_bucket_name>/$user/
  • Search for # Creating final tarball section and right after this line chown admin:$user $BACKUP/$user.$DATE.tar add new code:
# AWS UPLOAD
aws s3 cp $BACKUP/$user.$DATE.tar $bucket --storage-class REDUCED_REDUNDANCY
echo -e "$(date "+%F %T") AWS: Uploaded and backed. $user.$DATE.tar"
msg="$msg\n$(date "+%F %T") AWS: Uploaded and backed. $user.$DATE.tar"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment