Automated and scheduled backup of a folder on macOS to AWS S3 using launchctl
. I am using this to backup my Calibre library.
cp env.mjs.sample env.mjs
and add values for AWS account ID (defensive check, so global profile changes don't accidently upload to another bucket), local folder, s3 bucket- Edit
LaunchAgent-Examples/dev.zoid.calibre-backup-zx.plist
and set correct path for node, index.mjs from your machine. By default, it runs on 30th minute of each hour, please feel free to change that behavior as well, relevant docs cp ./LaunchAgent-Examples/dev.zoid.calibre-backup-zx.plist ~/Library/LaunchAgents
or use symlinklaunchctl load ~/Library/LaunchAgents/dev.zoid.calibre-backup-zx.plist
(Ifload
fails, tryunload
and thenload
)
stdout
-tail -f /tmp/dev.zoid.calibre-backup-zx.out
stderr
-tail -f /tmp/dev.zoid.calibre-backup-zx.err
To restore, you can use one the following commands
aws s3 sync s3://<bucket> <local-folder>
, docsaws s3 cp s3://<bucket> <local-folder> --recursive
docs
aws s3 sync
doesn't remove files from the S3 bucket. It is add only.