dendrite/aws-s3-backup/files/writefreely-s3-backup.sh
changeset 163 40b78af86337
parent 159 05d0cf32e077
equal deleted inserted replaced
162:a7a64ed07204 163:40b78af86337
       
     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