writefreely/aws-s3-backup/files/writefreely-s3-backup.sh
changeset 159 05d0cf32e077
parent 157 5e5c9e605142
equal deleted inserted replaced
158:1b7ccb729164 159:05d0cf32e077
       
     1 #!/bin/bash
       
     2 
       
     3 BUCKET=$1
       
     4 BACKUP_DIR=$2
       
     5 BACKUP_TAR="/tmp/$BUCKET.tgz"
       
     6 
       
     7 tar -zc -f $BACKUP_TAR $BACKUP_DIR
       
     8 aws s3 mb "s3://$BUCKET/"
       
     9 aws s3api put-bucket-versioning --bucket "$BUCKET" --versioning-configuration Status=Enabled
       
    10 aws s3api put-bucket-lifecycle-configuration --bucket "$BUCKET" --lifecycle-configuration "file:///usr/local/share/writefreely-s3-backup-lifecycle.json"
       
    11 aws s3 cp $BACKUP_TAR "s3://$BUCKET/"
       
    12 
       
    13 rm $BACKUP_TAR