Skip to content

Instantly share code, notes, and snippets.

@daliborgogic
Last active July 18, 2019 22:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save daliborgogic/990cc5b556ccb69859797f633b1593f0 to your computer and use it in GitHub Desktop.
Save daliborgogic/990cc5b556ccb69859797f633b1593f0 to your computer and use it in GitHub Desktop.
Syncs directories and S3 prefixes. Recursively copies new and updated files from the source directory to the destination.
*/10 * * * * /home/dlbr/documents/scripts/s3sync.sh >> /home/dlbr/documents/logs/s3sync.log 2>&1
#!/bin/bash
/usr/local/bin/aws s3 sync
| /home/dlbr/
| s3://dlbr/
# Displays the operations that would be performed using the specified
# command without actually running them.
# | --dryrun
| --endpoint "https://sfo3.digitaloceanspaces.com"
# (string) Exclude all files or objects from the command that matches
# the specified pattern.
| --exclude "*"
# (string) Don't exclude files or objects in the command that match
# the specified pattern.
| --include "apps/*"
| --include "backups/*"
| --include "desktop/*"
| --include "documents/*"
| --include "music/*"
| --include "pictures/*"
| --include "templates/*"
| --include "videos/*"
# (boolean) When syncing from S3 to local, same-sized items will be ignored only
# when the timestamps match exactly. The default behavior is to ignore
# same-sized items unless the local version is newer than the S3 version.
# | --exact-timestamps
# (boolean) Makes the size of each key the only criteria used to decide whether
# to sync from source to destination.
# | --size-only
# (boolean) Delete files that exist in the destination but not in the source are deleted
# during sync.
| --delete
XDG_DOWNLOAD_DIR="$HOME/downloads"
XDG_TEMPLATES_DIR="$HOME/templates"
XDG_PUBLICSHARE_DIR="$HOME/public"
XDG_DOCUMENTS_DIR="$HOME/documents"
XDG_MUSIC_DIR="$HOME/music"
XDG_PICTURES_DIR="$HOME/pictures"
XDG_VIDEOS_DIR="$HOME/videos"
@daliborgogic
Copy link
Author

daliborgogic commented Jul 17, 2019

# Make the script executable
$ chmod -x s3sync.sh

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment