backup-scheduler
backup-scheduler copied to clipboard
launchd based backup scheduler
Backup Scheduler
Automated and scheduled backup of a folder on macOS to AWS S3 using launchctl. I am using this to backup my Calibre library.
Setup
cp env.mjs.sample env.mjsand 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.plistand 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/LaunchAgentsor use symlinklaunchctl load ~/Library/LaunchAgents/dev.zoid.calibre-backup-zx.plist(Ifloadfails, tryunloadand thenload)
Monitoring
stdout-tail -f /tmp/dev.zoid.calibre-backup-zx.outstderr-tail -f /tmp/dev.zoid.calibre-backup-zx.err
Restore
To restore, you can use one the following commands
aws s3 sync s3://<bucket> <local-folder>, docsaws s3 cp s3://<bucket> <local-folder> --recursivedocs
Notes
aws s3 syncdoesn't remove files from the S3 bucket. It is add only.