Created
April 27, 2016 17:11
-
-
Save kitwalker12/209b0b611f1a11c5056497aeb1e44528 to your computer and use it in GitHub Desktop.
S3 Backup locally script (use absolute paths for files)
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 characters
0 21 * * * s3backup.sh >> crontab.out 2> crontab.err & | |
0 5 * * * s3stopbackup.sh >> crontab.out 2> crontab.err & |
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 characters
#!/bin/sh | |
export PATH=/opt/bin:/opt/sbin:/usr/bin/:/usr/local/bin:$PATH | |
if (ps -A | grep aws | grep -v grep) | |
then | |
echo "s3backup.sh: `date +%Y%m%d-%H%M` - Backup already in progress" >> aws-sync.log | |
exit | |
fi | |
echo "s3backup.sh: `date +%Y%m%d-%H%M` - Backup started" >> aws-sync.log | |
aws s3 sync s3://<my-bucket> <local-backup-path> >> aws-sync.log | |
echo "s3backup.sh: `date +%Y%m%d-%H%M` - Backup completed" >> aws-sync.log |
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 characters
#!/bin/sh | |
if (ps -A | grep aws | grep -v grep) | |
then | |
kill `ps -A | grep s3backup.sh | grep -v grep | awk '{print $1}'` | |
echo "s3stopbackup.sh: `date +%Y%m%d-%H%M` - s3backup.sh killed" >> aws-sync.log | |
kill `ps -A | grep aws | grep -v grep | awk '{print $1}'` | |
echo "s3stopbackup.sh: `date +%Y%m%d-%H%M` - aws killed" >> aws-sync.log | |
else | |
echo "s3stopbackup.sh: `date +%Y%m%d-%H%M` - aws not running" >> aws-sync.log | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment