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.52k stars 91 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
zahlman commented 1 week 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

Suppose for example that OP most recently made a snapshot for the Ubuntu system, and now tries to make one for the Fedora system. Does Timeshift know which is the "most recent Fedora snapshot"? Because the Ubuntu snapshot would have completely different files, and so the benefit of using hard links to avoid redundant copies would be lost. It can't make a hard link unless it can find the target, and it can't check whether the file actually changed unless it can find the reference to compare against.

abertolli commented 1 week ago

I guess maybe we need to define the specifics of the use case here. (I'm imagining a dual-boot system sharing a disk for Timeshift.) Even two different Ubuntu systems should only be restored from their own identified snapshots. So it sounds like a UUID for the system being backed up maybe needs to be created, or else use the UUID of the disk(s). Restores should only happen back to devices/partitions associated with the backup.

Would that take care of it? Or are there other use cases? I also think more flexibility with allowing users to define paths might be a good idea.

zahlman commented 1 week ago

I guess maybe we need to define the specifics of the use case here. (I'm imagining a dual-boot system sharing a disk for Timeshift.)

That's what I had in mind, yes. In my case, I currently use Mint (for convenience, not out of lack of Linux knowledge) with separate / and /home partitions, and in the future I'm considering carving out another small partition to act as / for Arch or Manjaro.

...a UUID for the system being backed up.... Would that take care of it? Or are there other use cases? I also think more flexibility with allowing users to define paths might be a good idea.

As long as the system is smart enough to use this information for its hard-linking logic, I think it would be sufficient. People who want to organize the snapshots differently, just to have a differenly-organized collection, could do so easily enough with their own rsyncing.