This is a small script that backups btrfs snapshots organized in a Timeshift structure to another place. This can be used to backup the snapshots to a different drive.
Whenever possible the script will copy the snapshots incremental.
All @* folders under the <ROOT> folder are considered snapshots.
The following figure shows an example layout:
<ROOT>
├── 2021-05-06_02-03-24
│ └── @
├── 2021-05-16_17-24-47
│ ├── @
│ └── @home
..............
└── 2021-05-17_00-57-13
├── @
└── @home
To copy the snapshots to an arbitray destination <DEST> execute:
backup_btrfs_timeshift --root=<ROOT> --destination=<DEST>If your destination is another drive and you want to make sure it was properly mounted (so you don't just copy the snapshots into a "normal" folder) it is advisable to use the --force-mount option.
- If
--force-mountoption was set or the<DEST>doesn't exist yet, try to mount<DEST>(Seeman fstabon how to configure mount for this behaviour) - Search for all possible
@*folders at second level. - For each possible
@*subvolume candidate, search all folders (subdir) at first level if they contain said candidate:- Search for orphaned readonly snapshots (pendant in
<ROOT>got deleted) and delete them at<ROOT>and<DEST>(unless--no-deletespecified) - Create a readonly snapshot copy at
<ROOT>/../readonly/subdirbecause only they can be send viabtrfs send - Sync readonly snapshot to
<DEST>/snapshots/subdir. (Incremental sync is automatically applied infindorder)
- Search for orphaned readonly snapshots (pendant in
- dry-run option