mirror of
https://github.com/wmutschl/timeshift-autosnap-apt.git
synced 2026-08-19 18:38:24 +08:00
Added rsync of boot and efi folders
This commit is contained in:
@@ -5,6 +5,7 @@ Timeshift auto-snapshot script which runs before `apt upgrade|install|remove` us
|
|||||||
* This scrips is a fork of [timeshift-autosnap](https://gitlab.com/gobonja/timeshift-autosnap) from the [AUR](https://aur.archlinux.org/cgit/aur.git/tree/PKGBUILD?h=timeshift-autosnap) for Arch and Arch based distros but adapted for usage in Debian based systems which use apt as their package manager.
|
* This scrips is a fork of [timeshift-autosnap](https://gitlab.com/gobonja/timeshift-autosnap) from the [AUR](https://aur.archlinux.org/cgit/aur.git/tree/PKGBUILD?h=timeshift-autosnap) for Arch and Arch based distros but adapted for usage in Debian based systems which use apt as their package manager.
|
||||||
* Creates [Timeshift](https://github.com/teejee2008/timeshift) snapshots with unique comment.
|
* Creates [Timeshift](https://github.com/teejee2008/timeshift) snapshots with unique comment.
|
||||||
* Deletes old snapshots which are created using this script.
|
* Deletes old snapshots which are created using this script.
|
||||||
|
* Makes a copy of `/boot` and `/boot/efi` to `/boot.backup` before the call to timeshift for more secure restore options.
|
||||||
* Can be manually executed by running `sudo timeshift-autosnap-apt` command.
|
* Can be manually executed by running `sudo timeshift-autosnap-apt` command.
|
||||||
* Autosnaphot can be temporarily skipped by setting SKIP_AUTOSNAP environment variable (e.g. `sudo SKIP_AUTOSNAP= apt upgrade`)
|
* Autosnaphot can be temporarily skipped by setting SKIP_AUTOSNAP environment variable (e.g. `sudo SKIP_AUTOSNAP= apt upgrade`)
|
||||||
* Supports both `BTRFS` and `RSYNC` mode.
|
* Supports both `BTRFS` and `RSYNC` mode.
|
||||||
@@ -32,15 +33,17 @@ After this, optionally, make changes to the configuration file:
|
|||||||
```bash
|
```bash
|
||||||
sudo nano /etc/timeshift-autosnap-apt.conf
|
sudo nano /etc/timeshift-autosnap-apt.conf
|
||||||
```
|
```
|
||||||
|
For example, if you don't have a dedicated `/boot` partition, then you should set `snapshotBoot=false`.
|
||||||
|
|
||||||
## Configuration
|
## Configuration
|
||||||
The configuration file is located in `/etc/timeshift-autosnap-apt.conf`. You can set the following options:
|
The configuration file is located in `/etc/timeshift-autosnap-apt.conf`. You can set the following options:
|
||||||
|
* `snapshotBoot`: If set to **true** /boot folder will be cloned into /boot.backup before the call to timeshift. Note that this will not include the /boot/efi folder. Default: **true**
|
||||||
|
* `snapshotEFI`: If set to **true** /boot/efi folder will be cloned into /boot.backup/efi before the call to timeshift. Default: **true**
|
||||||
* `skipAutosnap`: If set to **true** script won't be executed. Default: **false**.
|
* `skipAutosnap`: If set to **true** script won't be executed. Default: **false**.
|
||||||
* `deleteSnapshots`: If set to **false** old snapshots won't be deleted. Default: **true**
|
* `deleteSnapshots`: If set to **false** old snapshots won't be deleted. Default: **true**
|
||||||
* `maxSnapshots`: Defines **maximum** number of old snapshots to keep. Default: **3**
|
* `maxSnapshots`: Defines **maximum** number of old snapshots to keep. Default: **3**
|
||||||
* `snapshotDescription` Defines **value** used to distinguish snapshots created using timeshift-autosnap-apt. Default: **{timeshift-autosnap-apt} {created before upgrade}**
|
* `snapshotDescription` Defines **value** used to distinguish snapshots created using timeshift-autosnap-apt. Default: **{timeshift-autosnap-apt} {created before upgrade}**
|
||||||
|
|
||||||
|
|
||||||
## Test functionality
|
## Test functionality
|
||||||
To test the functionality, try (re)installing some package `maxSnapshots` number of times, e.g.
|
To test the functionality, try (re)installing some package `maxSnapshots` number of times, e.g.
|
||||||
```bash
|
```bash
|
||||||
@@ -141,8 +144,8 @@ or for RSYNC:
|
|||||||
|
|
||||||
## Ideas and contributions
|
## Ideas and contributions
|
||||||
- [x] Ask to be included into official Timeshift package, [status pending](https://github.com/teejee2008/timeshift/issues/595).
|
- [x] Ask to be included into official Timeshift package, [status pending](https://github.com/teejee2008/timeshift/issues/595).
|
||||||
- [ ] Add systemd-boot entry to boot into automatically generated snapshots (test on Pop!_OS)
|
- [x] Copy /boot and /boot/efi to filesystem for better control option when restoring (tested on Pop!_OS)
|
||||||
- [ ] Add grub boot entry to boot into automatically generated snapshots, similar to ARCH package [grub-btrfs](https://github.com/Antynea/grub-btrfs) (test on Ubuntu)
|
- [ ] Check and adapt [grub-btrfs](https://github.com/Antynea/grub-btrfs) for compatibility with Debian-based systems and this script (test on Ubuntu) to automatically create menu entries into grub.
|
||||||
|
|
||||||
**All new ideas and contributors are welcomed, just open an issue for that!**
|
**All new ideas and contributors are welcomed, just open an issue for that!**
|
||||||
|
|
||||||
|
|||||||
@@ -34,6 +34,21 @@ if $(get_property "skipAutosnap" "boolean" "false") ; then
|
|||||||
echo "==> skipping timeshift-autosnap-apt due skipAutosnap in $CONF_FILE set to TRUE." >&2; exit 0;
|
echo "==> skipping timeshift-autosnap-apt due skipAutosnap in $CONF_FILE set to TRUE." >&2; exit 0;
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if $(get_property "snapshotBoot" "boolean" "true") ; then
|
||||||
|
echo "Rsyncing /boot into the filesystem before the call to timeshift." >&2;
|
||||||
|
mkdir -p /boot.backup
|
||||||
|
cmd="rsync -au --exclude 'efi' --delete /boot/ /boot.backup/"
|
||||||
|
eval $cmd
|
||||||
|
fi
|
||||||
|
|
||||||
|
if $(get_property "snapshotEFI" "boolean" "true") ; then
|
||||||
|
echo "Rsyncing /boot/efi into the filesystem before the call to timeshift." >&2;
|
||||||
|
mkdir -p /boot.backup
|
||||||
|
mkdir -p /boot.backup/efi
|
||||||
|
cmd="rsync -au --delete /boot/efi/ /boot.backup/efi/"
|
||||||
|
eval $cmd
|
||||||
|
fi
|
||||||
|
|
||||||
readonly SNAPSHOT_DESCRIPTION=$(get_property "snapshotDescription" "string" "{timeshift-autosnap-apt} {created before upgrade}")
|
readonly SNAPSHOT_DESCRIPTION=$(get_property "snapshotDescription" "string" "{timeshift-autosnap-apt} {created before upgrade}")
|
||||||
|
|
||||||
timeshift --create --comments "$SNAPSHOT_DESCRIPTION" || { echo "Unable to run timeshift-autosnap-apt! Please close Timeshift and try again. Script will now exit..." >&2; exit 1; }
|
timeshift --create --comments "$SNAPSHOT_DESCRIPTION" || { echo "Unable to run timeshift-autosnap-apt! Please close Timeshift and try again. Script will now exit..." >&2; exit 1; }
|
||||||
|
|||||||
@@ -2,6 +2,14 @@
|
|||||||
# /etc/timeshift-autosnap.conf
|
# /etc/timeshift-autosnap.conf
|
||||||
#
|
#
|
||||||
|
|
||||||
|
# snapshotBoot defines if /boot folder should be cloned into /boot.backup before the call to timeshift.
|
||||||
|
# Default value is true.
|
||||||
|
snapshotBoot=true
|
||||||
|
|
||||||
|
# snapshotEFI defines if /boot/efi folder should be cloned into /boot.backup/efi before the call to timeshift.
|
||||||
|
# Default value is true.
|
||||||
|
snapshotEFI=true
|
||||||
|
|
||||||
# skipAutosnap defines if timeshift-autosnap execution should be skipped.
|
# skipAutosnap defines if timeshift-autosnap execution should be skipped.
|
||||||
# Default value is false.
|
# Default value is false.
|
||||||
skipAutosnap=false
|
skipAutosnap=false
|
||||||
|
|||||||
Reference in New Issue
Block a user