The problem
Database dumps, Docker configuration, the hypervisor configuration and a 226 GiB photo library all sat on one NAS, next to the live data. A dead NAS, a fire or ransomware on the network would have taken the originals and the backups together.
That breaks the 3-2-1 rule: three copies of the data, on two kinds of storage, with one copy off-site.
What I built
- SourceNAS backup foldersDatabase dumps, config archives, photos
- Backup hostUpload scriptStarted by three systemd timers
- Encryptrclone cryptBefore anything leaves the server
- CredentialUpload-only IAM keyList, upload, read. No delete.
- DestinationS3 bucketPrivate, versioned, lifecycle rules
The server never deletes anything in S3. Lifecycle rules inside the bucket do all the clean-up.
| Data | How often | Kept | Storage class |
|---|---|---|---|
| 8 database dumps | Daily | 30 days | S3 Standard |
| Docker and hypervisor config archives | Weekly | 8 copies | S3 Standard |
| Photo originals | Daily, new files only | Indefinitely | Glacier Deep Archive |
Design decisions
1. The server's key can upload but can't delete
The IAM policy allows list, upload and read on one bucket and nothing else. There is no delete permission. If the backup host is compromised, the attacker gets a key that can't destroy the backups, and versioning keeps the previous copy of anything overwritten for 30 days.
That is also why the script uses rclone copy and never rclone sync. sync deletes files in the destination that were deleted at the source, so it would carry an accidental or malicious deletion straight into the backup.
2. Encrypted before it leaves the server
S3's default encryption protects the disks, but AWS holds those keys. Everything here also goes through rclone crypt with a password that exists only in my password manager. Someone with access to the AWS account still sees only ciphertext.
3. Storage class chosen by how long the data lives
Glacier Deep Archive costs about 23 times less than S3 Standard, but it has a 180-day minimum charge and a 12 to 48 hour restore. Photos are kept indefinitely and only needed in a disaster, so they go there. Configs and dumps live 30 to 57 days. In Glacier they would be billed for 90 to 180 days, which would cost more, so they stay in Standard.
4. I sized the data before moving it
The “config-only” archive was 4.2 GB. I looked inside before uploading and found AI model files, dated database copies, caches, and some files holding live secrets, including a VPN private key. I excluded the junk and the secrets, cut the archive to 1.2 GB, locked down its file permissions and rotated the exposed keys. Then I uploaded.
5. It fails loudly
The script refuses to upload a dump older than 36 hours. If the nightly dump job breaks, the off-site job fails too and sends an alert, instead of quietly re-uploading an old file. The timers catch up after downtime, and the photo job takes a lock so a long upload and the next night's run never overlap.
6. A leaked key only works from home
The policy also refuses every request that doesn't come from my home internet address, so a copy of the key leaked from a config file is useless anywhere else. I tested it in the IAM Policy Simulator: denied from another address, allowed from home.
First run
| Job | Data | Time |
|---|---|---|
| Daily | 8 database dumps | 21 seconds |
| Weekly | 1.2 GB config archive | 49 seconds |
| Photos | 226 GiB, 31,909 files | 1 hour 25 minutes |
Restore, tested
I ran two tests. Both were decrypted on a different machine using only the password from my password manager.
- A 114 MB database dump in S3 Standard: downloaded in under a minute, decrypted in 0.3 seconds.
- A photo from Glacier Deep Archive, which has to be restored before it can be downloaded: a Bulk restore had it ready 36 hours later, inside the 48 hours AWS quotes. Decrypted in 0.2 seconds.
Both SHA-256 checksums matched the originals on the NAS exactly.
If the backup host and the NAS were both gone, the AWS console plus one password would get the data back, byte for byte.
The first bill
November's bill was $1.75. About half was the one-time charge for moving the photos into Deep Archive, which I had planned for. The surprise was $0.76 in requests: 151,000 of them for 32,000 files.
The upload log showed why. rclone was listing the bucket one folder at a time, and my photo library is spread across thousands of small folders. Every nightly run made about 17,000 paid requests, even with nothing new to upload. That's about $2.50 a month, four times the storage cost. One flag, --fast-list, turned it into a single listing of about 33 requests, and the nightly check went from a minute to 5 seconds.
On S3, requests are a line item. Read the bill by usage type, not just the total.
Known limits and next steps
- Overwrites are recoverable for 30 days, not forever. I first had this at one day and caught it reviewing my own write-up. Next: S3 Object Lock, so no copy can be replaced for a set time, even by an admin.
- Monitoring checks failures, not silence. Next: add a staleness check on the last-success stamp files the script writes.
- Photo recovery is slow by design. Deep Archive takes up to 48 hours to restore (36 in my test), plus the download. An email now arrives when each restore completes.