linuxmint / timeshift

System restore tool for Linux. Creates filesystem snapshots using rsync+hardlinks, or BTRFS snapshots. Supports scheduled snapshots, multiple backup levels, and exclude filters. Snapshots can be restored while system is running or from Live CD/USB.
2.26k stars 81 forks source link

Rename timeshift backup folder for multiple linux and same Backup device #193

Open lamyergeier opened 1 year ago

lamyergeier commented 1 year ago

Is your feature request related to a problem? Please describe. I use dual boot of Fedora and Ubuntu. And I have a separate disk that I want to store timeshift backup of both these operating system. Unfortunately timeshift does not let us define the directory name in the backup device!

Describe the solution you'd like Instead of the folder timeshift, I would like it to be renamed as timeshift_Ubuntu and timeshift_Fedora.

How can I do it?

abertolli commented 1 year ago

Why do you need to define the directory? Even though all the snapshots are stored in the same directory, each one is identified by a unique id, e.g.

2023-05-26_21-35-47/info.json:  "sys-uuid" : "7faa9544-2300-45d5-baf2-68f2ba22a4e4",
2023-05-26_21-47-52/info.json:  "sys-uuid" : "7faa9544-2300-45d5-baf2-68f2ba22a4e4",
2023-05-26_22-44-13/info.json:  "sys-uuid" : "77f3a8c7-a239-43e3-8d83-ecb50ae12b16",
Sadi58 commented 1 year ago

Indeed, timeshift-gtk displays distro name as well, so one can restore the right snapshot, but it's not the case when you're stuck with the terminal only. So, I've been using the startup script below which checks the current distro, and makes sure that the timeshift back folder for the other distro is renamed as "timeshift_, so the folder named "timeshift" is used for snapshots of the current distro only.

distro="$(lsb_release -i -s 2> /dev/null)"
timeshift="$(ls "</Backup/Device/Path>" | grep "timeshift_" | awk -F "_" '{print $2}')"
my_password=<Password>
if [[ "$distro" == "$timeshift" ]]; then
    if [[ "$distro" == "<Distro1>" ]]; then
        echo $my_password | sudo -S mv "</Backup/Device/Path>/timeshift" "</Backup/Device/Path>/timeshift_<Distro2>"
        echo $my_password | sudo -S mv "</Backup/Device/Path>/timeshift_<Distro1>" "</Backup/Device/Path>/timeshift"
    elif [[ "$distro" == "<Distro2>" ]]; then
        echo $my_password | sudo -S mv "</Backup/Device/Path>/timeshift" "</Backup/Device/Path>/timeshift_<Distro1>"
        echo $my_password | sudo -S mv "</Backup/Device/Path>/timeshift_<Distro2>" "</Backup/Device/Path>/timeshift"
    fi
fi