-
-
Save pulpfree/c942376ab232abb2f6a1ce6b0d1a1e9a to your computer and use it in GitHub Desktop.
Revisions
-
eladnava revised this gist
Jun 10, 2016 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -11,7 +11,7 @@ # 8) Set up a daily backup at midnight via `crontab -e`: # 0 0 * * * /home/ubuntu/backup.sh > /home/ubuntu/backup.log # DB host (secondary preferred as to avoid impacting primary performance) HOST=db.example.com # DB name -
eladnava revised this gist
Jun 7, 2016 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -42,7 +42,7 @@ echo "Backing up $HOST/$DBNAME to s3://$BUCKET/ on $TIME"; /usr/bin/mongodump -h $HOST -d $DBNAME -o $DEST # Create tar of backup directory /bin/tar cvf $TAR -C $DEST . # Upload tar to s3 /usr/bin/aws s3 cp $TAR s3://$BUCKET/ -
eladnava revised this gist
Jun 7, 2016 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -54,4 +54,4 @@ echo "Backing up $HOST/$DBNAME to s3://$BUCKET/ on $TIME"; /bin/rm -rf $DEST # All done echo "Backup available at https://s3.amazonaws.com/$BUCKET/$TIME.tar" -
eladnava revised this gist
Jun 7, 2016 . 1 changed file with 8 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -5,7 +5,7 @@ # 2) Run sudo apt-get install awscli to install the AWSCLI # 3) Run aws configure (enter s3-authorized IAM user and specify region) # 4) Fill in DB host + name # 5) Create S3 bucket for the backups and fill it in below (set a lifecycle rule to expire files older than X days in the bucket) # 6) Run chmod +x backup.sh # 7) Test it out via ./backup.sh # 8) Set up a daily backup at midnight via `crontab -e`: @@ -35,6 +35,9 @@ TAR=$DEST/../$TIME.tar # Create backup dir (-p to avoid warning if already exists) /bin/mkdir -p $DEST # Log echo "Backing up $HOST/$DBNAME to s3://$BUCKET/ on $TIME"; # Dump from mongodb host into backup directory /usr/bin/mongodump -h $HOST -d $DBNAME -o $DEST @@ -48,4 +51,7 @@ TAR=$DEST/../$TIME.tar /bin/rm -f $TAR # Remove backup directory /bin/rm -rf $DEST # All done echo "Backup available at https://s3.amazonaws.com/$BUCKET/$TAR" -
eladnava revised this gist
Jun 7, 2016 . 1 changed file with 8 additions and 7 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,13 +1,14 @@ #!/bin/sh # Make sure to: # 1) Name this file `backup.sh` and place it in /home/ubuntu # 2) Run sudo apt-get install awscli to install the AWSCLI # 3) Run aws configure (enter s3-authorized IAM user and specify region) # 4) Fill in DB host + name # 5) Create S3 bucket and fill it in below # 6) Run chmod +x backup.sh # 7) Test it out via ./backup.sh # 8) Set up a daily backup at midnight via `crontab -e`: # 0 0 * * * /home/ubuntu/backup.sh > /home/ubuntu/backup.log # DB host (secondary) -
eladnava revised this gist
Jun 7, 2016 . No changes.There are no files selected for viewing
-
eladnava created this gist
Jun 7, 2016 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,50 @@ #!/bin/sh # Make sure to: # 1) Run sudo apt-get install awscli to install the AWSCLI # 2) Run aws configure (enter s3-authorized IAM user and specify region) # 3) Fill in DB host + name # 4) Create S3 bucket and fill it in below # 5) Run chmod +x backup.sh # 6) Test it out via ./backup.sh # 7) Set up a daily backup at midnight via `crontab -e`: # 0 0 * * * /home/ubuntu/backup.sh > /home/ubuntu/backup.log # DB host (secondary) HOST=db.example.com # DB name DBNAME=my-db # S3 bucket name BUCKET=s3-bucket-name # Linux user account USER=ubuntu # Current time TIME=`/bin/date +%d-%m-%Y-%T` # Backup directory DEST=/home/$USER/tmp # Tar file of backup directory TAR=$DEST/../$TIME.tar # Create backup dir (-p to avoid warning if already exists) /bin/mkdir -p $DEST # Dump from mongodb host into backup directory /usr/bin/mongodump -h $HOST -d $DBNAME -o $DEST # Create tar of backup directory /bin/tar cvf $TAR $DEST # Upload tar to s3 /usr/bin/aws s3 cp $TAR s3://$BUCKET/ # Remove tar file locally /bin/rm -f $TAR # Remove backup directory /bin/rm -rf $DEST