@@ -1690,6 +1690,9 @@ public class Main : GLib.Object{
16901690
16911691 set_tags(snapshot); // set_tags() will update the control file
16921692
1693+ // Perform any post-backup actions
1694+ this . run_post_backup_hooks(snapshot_path);
1695+
16931696 return snapshot;
16941697 }
16951698
@@ -1781,18 +1784,27 @@ public class Main : GLib.Object{
17811784 set_tags(snapshot); // set_tags() will update the control file
17821785
17831786 // Perform any post-backup actions
1784- log_debug(" Running post-backup tasks..." );
1785-
1786- string sh = " test -d \" /etc/timeshift/backup-hooks.d\" &&" +
1787- " export TS_SNAPSHOT_PATH=\" " + snapshot_path + " \" &&" +
1788- " run-parts --verbose /etc/timeshift/backup-hooks.d" ;
1789- exec_script_sync(sh, null , null , false , false , false , true );
1790-
1791- log_debug(" Finished running post-backup tasks..." );
1787+ this . run_post_backup_hooks(snapshot_path);
17921788
17931789 return snapshot;
17941790 }
17951791
1792+ private void run_post_backup_hooks (string snapshot_path ) {
1793+ const string backuphooksdir = " /etc/timeshift/backup-hooks.d" ;
1794+ FileType fileType = File . new_for_path(backuphooksdir). query_file_type(FileQueryInfoFlags . NONE );
1795+ if (fileType == FileType . DIRECTORY ) {
1796+ log_debug(" Running post-backup tasks..." );
1797+
1798+ string sh = " export TS_SNAPSHOT_PATH=\" " + snapshot_path + " \" &&" +
1799+ " run-parts --verbose \"%s\" " . printf(backuphooksdir);
1800+ exec_script_sync(sh, null , null , false , false , false , true );
1801+
1802+ log_debug(" Finished running post-backup tasks..." );
1803+ } else {
1804+ log_debug(" Backup hooks skipped, because %s does not exist" . printf(backuphooksdir));
1805+ }
1806+ }
1807+
17961808 private void set_tags (Snapshot snapshot ){
17971809
17981810 // add tags passed on commandline for both --check and --create
0 commit comments