Backup Solution
The snippet can be accessed without any authentication.
Authored by
izzy
Edited
# 3-2-1 Backups: (1) Configuration to create the first structured copy
## Media backups
Photos & videos are automatically backed up to https://photos.insert.moe from mobile devices.
Screenshots are backed up to https://screenshots.insert.moe by:
- Mobile devices (using Immich2 dual app)
- Windows PC
```bash
immich upload C:\Users\mink\Pictures\Screenshots
immich upload --recursive C:\Users\mink\Documents\ShareX\Screenshots
```
- Framework
```bash
nix-shell -p nodejs --command fish
npx @immich/cli upload "/home/insert/Videos/Screencasts/"
npx @immich/cli upload "/home/insert/Pictures/Screenshots/"
```
- Mac Mini
```bash
immich upload "/Users/insert/Pictures/Screenshots"
find /Users/insert/Pictures/Screenshots -mtime +30 -exec rm {} +
```
### Some neat snippets
Read dates from file names and write them into "date taken"/"media created" fields
```bash
exiftool "-alldates<filename" *.mp4
```
Restore original files (i.e. .original_jpg files)
```bash
exiftool "-restore_original" *.jpg
```
Convert files between formats but preserve the creation / modification dates
```bash
magick mogrify -format png -define preserve-timestamp=true *.bmp
```
<br/><br/><br/><br/>
# 3-2-1 Backups: (2) Creating Restic repositories
## redstone
```bash
cd /tank/backups
# run backup for Immich (photos & videos)
./run_immich.sh
# ... and screenshots:
./run_immich_screenshots.sh
# run backup for all other services
SECRET_MONGO_SU_PASSWORD=omitted ./run_services.sh
# you can find the full command in BitWarden
# run backups for NAS drive
./run_tank.sh
```
## Revolt
Before starting backups, make sure permissions are correct on the remote:
```bash
sudo chown -R revolt:revolt /tank/backups/revolt
```
To backup individual nodes, run the following:
```bash
/root/.infra/hosts/$HOSTNAME/backup.sh
```
Applicable nodes:
- aux 1
- prod 3
To backup the database, SSH into the database node, run the following:
```bash
/root/.infra/hosts/$HOSTNAME/backup_db.sh
```
<br/><br/><br/><br/>
# 3-2-1 Backups: (3) Synchronising backups to cold storage
First things first, here is the list of Restic repositories:
| Storage Medium | Path | Description | Encryption |
|:-:|:--|:--|:-:|
| HDD | `/tank/backups/immich` | Photos & videos | Default key |
| HDD | `/tank/backups/immich_screenshots` | Screenshots & misc images/videos | Default key |
| HDD | `/tank/backups/services` | All relevant data from deployments on redstone | Default key |
| HDD | `/tank/backups/revolt` | Database and service backups for Revolt<br/>_Contains multiple repositories._ | Revolt key |
| SSD | `/backups/archive` | Copy of `/tank/archive`; Archival repository | Default key |
| SSD | `/backups/clips` | Copy of `/tank/clips`; Game recordings | Default key |
Before synchronising to the cloud, prune old revisions of files:
```bash
cd /tank/backups
./prune_repos.sh
# this will run:
restic forget --keep-last 1 --prune
# for all repositories
```
> ⚠️ This will not work properly if snapshot contents are changed, you may need to manually `forget <snapshot id> --prune` where appropriate.
Now we can synchronise to the object storage provider and ensure we delete old files:
```bash
# TODO
```
Please register or sign in to comment