Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Next] BTRFS custom hooks #381

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ You can selectively include items for backup from the ***Settings*** window. Sel
- **@** and **@home** subvolumes may be on same or different BTRFS volumes
- **@** may be on BTRFS volume and **/home** may be mounted on non-BTRFS partition
- If swap files are used they should not be located in **@** or **@home** and could instead be stored in their own subvolume, eg **@swap**
- Separate partitions (e.g. `/boot`) can be handled via custom created hooks (placed in `/etc/timeshift/backup-hooks.d/` and `/etc/timeshift/restore-hooks.d/`). Script naming must match `run-parts` [requirements](https://manpages.ubuntu.com/manpages/noble/man8/run-parts.8.html). Current snapshot path is exported as `TS_SNAPSHOT_PATH`.
- Other layouts are not supported
- Make sure, that you have selected subvolume *@* or */@* for root. You can check that executing script below, and if output is *OK*, then everything is alright.

Expand Down
2 changes: 1 addition & 1 deletion debian/control
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Homepage: https://github.com/linuxmint/timeshift

Package: timeshift
Architecture: any
Depends: ${shlibs:Depends}, ${misc:Depends}, rsync, btrfs-progs | btrfs-tools
Depends: ${shlibs:Depends}, ${misc:Depends}, rsync, debianutils, btrfs-progs | btrfs-tools
Replaces: timeshift-btrfs
Description: System restore utility
Timeshift is a system restore utility which takes snapshots
Expand Down
23 changes: 22 additions & 1 deletion src/Core/Main.vala
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ public class Main : GLib.Object{

log_debug("Main: check_dependencies()");

string[] dependencies = { "rsync","/sbin/blkid","df","mount","umount","fuser","crontab","cp","rm","touch","ln","sync","which"}; //"shutdown","chroot",
string[] dependencies = { "rsync","/sbin/blkid","df","mount","umount","fuser","crontab","cp","rm","touch","ln","sync","which", "run-parts"}; //"shutdown","chroot",

string path;
foreach(string cmd_tool in dependencies){
Expand Down Expand Up @@ -1693,6 +1693,16 @@ public class Main : GLib.Object{

set_tags(snapshot); // set_tags() will update the control file

// Perform any post-backup actions
log_debug("Running post-backup tasks...");

string sh = "test -d \"/etc/timeshift/backup-hooks.d\" &&" +
" export TS_SNAPSHOT_PATH=\"" + snapshot_path + "\" &&" +
" run-parts --verbose /etc/timeshift/backup-hooks.d";
exec_script_sync(sh, null, null, false, false, false, true);

log_debug("Finished running post-backup tasks...");

return snapshot;
}

Expand Down Expand Up @@ -3032,6 +3042,17 @@ public class Main : GLib.Object{

log_msg(_("Restore completed"));
thr_success = true;

// Perform any post-restore actions
log_debug("Running post-restore tasks...");

string sh = "test -d \"/etc/timeshift/restore-hooks.d\" &&" +
" export TS_SNAPSHOT_PATH=\"" + snapshot_to_restore.path + "\" &&" +
" run-parts --verbose /etc/timeshift/restore-hooks.d";

exec_script_sync(sh, null, null, false, false, false, true);

log_debug("Finished running post-restore tasks...");

if (restore_current_system){
log_msg(_("Snapshot will become active after system is rebooted."));
Expand Down