Created
January 21, 2017 22:08
-
-
Save StudioLE/af96acaf589c3d037e9c04baa9304773 to your computer and use it in GitHub Desktop.
Sync directory to S3
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
| */5 * * * * ~/sync.sh >> ~/sync.log 2>&1 |
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/bash | |
| echo "----" | |
| # Timestamp | |
| date | |
| # Create lock file | |
| ( | |
| # Exit with failure if already in use | |
| flock -n -e 9 || { echo "Exiting: Sync in progress" && exit 1; } | |
| # Sync directory to S3 | |
| # Use trickle to limit to 120 kB/s | |
| /usr/bin/trickle -s -u 120 /usr/local/bin/aws s3 sync /PATH/TO/DIRECTORY s3://BUCKET/PATH | |
| ) 9>/tmp/sync.lockfile | |
| # Timestamp | |
| date |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment