Naught McNoone recommended that I create a How To guide for this freshly found method.
Using Linux Mint's Timeshift application (though it should work with any Linux distribution that supports Timeshift), you may create a system image of a machine that has all of your installed programs, including exe files that run under Wine, and all of your preferred system settings. This image can be used to clone your OS configuration onto other PCs or to recover from a catastrophic system calamity, such as the death of a hard disk.
This is a method for backing up a system that includes not only the background files of your Linux OS but also all installed programs, operating system customizations and settings, and any customizations used in any programs you have. You can also potentially backup a few small files within the system if you'd like (such as test files to ensure programs open correctly, frequently used scripts, or instruction documents), but NOT large media file collections, as this would be a very wasteful and inconvenient way to back up that kind of stuff.
It should be mentioned that, in contrast to a clonezilla-style backup, the system Imade may be browsed to copy individual files if necessary, but this isn't the primary use case for it.
It should be mentioned that, in contrast to a clonezilla-style backup, the system Imade may be browsed to copy individual files if necessary, but this isn't the primary use case for it.
Keep in mind that although though the portable file you create will be enormous, it will typically be smaller than the overall size of your PC's partition. I completed this for a newly installed system after installing all of my programs, settings, customizations, etc., which added up to tens of gigabytes in and of themselves. I also completed the initial rounds of updates. Currently, I have a root partition of 100GB, a home partition of 500GB, and an additional 400GB data partition for large files.
The img file was around "64" GB, the portable 7z was "only" 30 GB, and the Timeshift USB fit on a "64" GB USB.
In the next section of the tutorial, we'll talk about compressing the timeshift image to make it into a fully portable 7z file as opposed to a special magic USB that stores your timeshift image. This particular USB is prone to damage, and it also comes with the general inconvenience of not being a file that can be easily copied from one location to another and requiring you to use up a USB as a Timeshift partition.
The processes outlined here are not that rapid and require careful attention to detail while following instructions.
but apply to any system you wish to maintain a copy of. What comes next could most likely be scripted to automate.
The compressed image can be created as follows:
1. Make a timeshift snapshot of the system using the different options to copy the home directory and other directories that it wouldn't normally copy. These directories are important to copy if you want to include programs (such exe files under Wine) that are located in the home directory in the picture. All files should be copied, including any hidden ones like the bash history.
1.5. Select "Include All Files" for /root and "Include Only Hidden Files" and "Include All Files" for /home/your_user_name in the Timeshift settings "Users" tab. Next, in the tab for filters:
(+) + /root/**
(+) + /home/your_user_name/**
(-) X /home/your_user_name/Documents/***
(-) X /home/your_user_name/Music/***
(-) X /home/your_user_name/Videos/***
(-) X /media/your_user_name/***
(-) X /media/any_permanently_mounted_data_partition_you_want_to_ignore/***
(-) X /mnt/***
(+) + /home/your_user_name/.**
(-) X /home/your_user_name/Pictures/***
where the colored figure displayed at the beginning of each line is represented by + or X, and the column to be checked is represented by (+) or (-). Make sure that's how these are displayed. Because I have a poor habit of using the Downloads folder as a store for some installed apps, there is no exclusion rule for it. If you would want, you can exclude it. Every subdirectory under /home/your_user_name/ that is not excluded will be backed up.
Hence, every file found right under /home/your_user_name/. In the event that you have any applications or settings saved in Documents, take this line off of the filter list.
2. Take this picture on the tiniest USB that will fit on it.
3. At this point, I would suggest rebooting the system and other things. In my use case, it took months to figure out how to make the timeshift USB and how to proceed. It is also possible to complete the next section using a completely different machine from the one used to create the initial Timeshift USB.
4. Execute the command sudo dd if=/dev/sdX of=/home/username/timeshift_img/NameBackupSDB.img status=progress.
Before you start, make sure you have enough free HDD space to accommodate the entire USB.
5. Launch 7z an SDBNameBackupCompressed from within the timeshift_img folder.7z NameBackupSDB.img -p -mhe=on -mx=3; mx=3 helps speed up the compression process by not attempting to optimize too much for file size; mhe=on is optional if you wish to encrypt the backup, which is a smart move if the system contained password files that you copied and are now stored within it during the original timeshift snapshot. Make sure you have enough HDD space before executing to accommodate a new 7z file that is roughly proportionate to the size of the image file. Observe that the compression is usually fairly good even though only the mx=3 compression level is used,
Timeshift snapshots can be compressed up to 50% of their original size, which is usually pretty good. This makes them far more compressible than pre-compressed media like picture or video files.
6. That 7z file is now completely portable, even though it can be very large. As long as the drive can handle BIG files (30GB or more for the 7z in my use case), you can save it on any drive, anyplace, and with any formatting (so NTFS formatted filesystems, but not FAT32 or exFAT).
Here's how to use it:
7. Start by installing your Linux OS fresh on a new system, ensure you install Timeshift within it if Timeshift isn't supplied by default (it is there by default in Mint 21.1, where I tested this). When installing make sure to match partition names, sizes and order to that of the original system you are cloning.
8. Once the fresh install is done and rebooted, so you don't have the live USB for it plugged in any more, copy the 7z file on to this system, uncompress it with 7z either via terminal or via the GUI archive extraction file program so as to create an extracted copy of NameBackupSDB.img on the new system.
9. Get an extra USB, larger than the one originally used for storing the snapshot, and use dd to write the img file to it. It is vital this be bigger than the original, it absolutely must not be smaller. If the original USB was 62GB*, even if only 30GB was used, you need a USB >62GB here even though only the first 30GB of the img file is used. I hear rumours that many drives keep a partition table at the very back end of the drive, so writing an overly large img file overwrites this and makes the drive useless until you've used gparted to wipe it and write a new partition table. I definitely found this the case, I had a 61555605504 byte original USB containing a 57GB timeshift partition plus free space, I initially tried to dd the img to a drive which had a real capacity of 61,530,439,680 bytes, dd gave no errors, but the USB created could not be read even though the only partition which mattered in the drive I had cloned from was only 57GB. I had to use Gparted to make a new partition table, which wiped what I had just dd'd on to it. I retried with a drive which read as 64GB actual capacity, all was fine this time.
sudo dd if=ExtractedNameBackupSDB.img of=/dev/sdc status=progress
sdc here is for the new USB ( >(original size) )you are writing to. If your original was, for example, 62GB and you can't find a truly 64GB USB, use a 128GB here.
*here you notice how important the diferences of advertised capacity and actual can be, many 64GB USBs are 62GB or 58GB... and you also note the irritaing differences of GB vs GiB (Giga vs Gibi, 1000 based vs 1024 based) and how you're never really sure which of Gb and GiB any given program displays figures in and a USB is advertised as
10. Safely eject the USB and restart the freshly installed system
11. When you have restarted, start timeshift on the new system and set it NOT to take automated (daily, or other timeframe) snapshots
11.5. Turn OFF screensaver settings, tell the PC not to go to sleep, or lock the screen
12. Now plug in the USB which you dd'd the img file to, in Timeshift's settings tell Timeshift to look to that USB's partition as the place for snapshots
13. Leaving timeshift's settings alone, proceed to restore the snapshot from that USB
13.5. At the "select target device" stage pick the paths for "/" and "/home" to be the relevant sdaY and sdaZ partitions of the internal HDD, leave "/boot" and "/boot/efi" as "Keep on root device". In bootloder options select the defaults (do "(Re)install Grub2 on:" and pick your SDA hard drive as the device, do not pick a partition, do not update initramfs, do "update grub menu").
14. Timeshift will do its stuff, and then put the PC in to a state where the whole screen is taken up by a listing of the files Timeshift is restoring
15. Then it will try to restart, and then it will crash
16. Power down the PC, and boot from he live USB again
17. With the live USB booted, mount the root partition of the internal HDD, and run
sudo caja
to create an elevated privilege file browser.
18. Browse to /etc/fstab on the internal HDD's root partition and open it in the elevated privilege text editor
19. Open the Live USB's "Disks" program
20. Edit /etc/fstab so each UUID it presently shows is replaced by the appropriate UUID seen in the Disks window, copy and paste from the Disks window to the /etc/fstab text file each UUID, or the EFI partition, root partition, home partition and any others. Note, if there were a way to work the other way round, telling the live system what UUIDs you want for each partition at an earlier point in time, I'd be interested in understanding that option too if anyone can tell me of ways to choose the UUID during installation of the OS to the HDD while booted from a Live USB.
21. Shut down the PC, remove the Live USB, now boot normally, log in, and open Timeshift again. Note that during pre-login the desktop background will match any custom one you have set, but after login it will still look like the default used on the fresh install.
22. At this point some parts of the snapshot have been restored, but some haven't, now we'll get them all restored
23. When you open Timeshift now it will have all the correct folder filters as were used when your original snapshot was made. Plug in your timeshift snapshot USB, select it as the device to restore from under "Location". When restoring from it use the same "select target device" settings as you did earlier on.
24. Allow it to restore, and go to the screen of scrolling file names again, and shut itself down
25. This time when it restarts it will crash again, you'll need to use the live USB again to make the /etc/fstab changes
26. With those changes made, the same way as before, shut down.
27. After that, remove the live USB, turn on the computer, and you'll have a fresh copy of the original system that was transferred using a fully portable 7z file 28. After that, you can utilize the USB that was used for the timeshift snapshot for regular file storage (only the larger later one, or both of them). In the event that you don't need to use up USB space with the timeshift snapshot, you can store the 7z file as a file on a sizable ntfs partition on any available data storage device. This allows you to generate a timeshift partition USB when needed.
I hope you found this useful.
Using Linux Mint's Timeshift application (though it should work with any Linux distribution that supports Timeshift), you may create a system image of a machine that has all of your installed programs, including exe files that run under Wine, and all of your preferred system settings. This image can be used to clone your OS configuration onto other PCs or to recover from a catastrophic system calamity, such as the death of a hard disk.
This is a method for backing up a system that includes not only the background files of your Linux OS but also all installed programs, operating system customizations and settings, and any customizations used in any programs you have. You can also potentially backup a few small files within the system if you'd like (such as test files to ensure programs open correctly, frequently used scripts, or instruction documents), but NOT large media file collections, as this would be a very wasteful and inconvenient way to back up that kind of stuff.
It should be mentioned that, in contrast to a clonezilla-style backup, the system Imade may be browsed to copy individual files if necessary, but this isn't the primary use case for it.
It should be mentioned that, in contrast to a clonezilla-style backup, the system Imade may be browsed to copy individual files if necessary, but this isn't the primary use case for it.
Keep in mind that although though the portable file you create will be enormous, it will typically be smaller than the overall size of your PC's partition. I completed this for a newly installed system after installing all of my programs, settings, customizations, etc., which added up to tens of gigabytes in and of themselves. I also completed the initial rounds of updates. Currently, I have a root partition of 100GB, a home partition of 500GB, and an additional 400GB data partition for large files.
The img file was around "64" GB, the portable 7z was "only" 30 GB, and the Timeshift USB fit on a "64" GB USB.
In the next section of the tutorial, we'll talk about compressing the timeshift image to make it into a fully portable 7z file as opposed to a special magic USB that stores your timeshift image. This particular USB is prone to damage, and it also comes with the general inconvenience of not being a file that can be easily copied from one location to another and requiring you to use up a USB as a Timeshift partition.
The processes outlined here are not that rapid and require careful attention to detail while following instructions.
but apply to any system you wish to maintain a copy of. What comes next could most likely be scripted to automate.
The compressed image can be created as follows:
1. Make a timeshift snapshot of the system using the different options to copy the home directory and other directories that it wouldn't normally copy. These directories are important to copy if you want to include programs (such exe files under Wine) that are located in the home directory in the picture. All files should be copied, including any hidden ones like the bash history.
1.5. Select "Include All Files" for /root and "Include Only Hidden Files" and "Include All Files" for /home/your_user_name in the Timeshift settings "Users" tab. Next, in the tab for filters:
(+) + /root/**
(+) + /home/your_user_name/**
(-) X /home/your_user_name/Documents/***
(-) X /home/your_user_name/Music/***
(-) X /home/your_user_name/Videos/***
(-) X /media/your_user_name/***
(-) X /media/any_permanently_mounted_data_partition_you_want_to_ignore/***
(-) X /mnt/***
(+) + /home/your_user_name/.**
(-) X /home/your_user_name/Pictures/***
where the colored figure displayed at the beginning of each line is represented by + or X, and the column to be checked is represented by (+) or (-). Make sure that's how these are displayed. Because I have a poor habit of using the Downloads folder as a store for some installed apps, there is no exclusion rule for it. If you would want, you can exclude it. Every subdirectory under /home/your_user_name/ that is not excluded will be backed up.
Hence, every file found right under /home/your_user_name/. In the event that you have any applications or settings saved in Documents, take this line off of the filter list.
2. Take this picture on the tiniest USB that will fit on it.
3. At this point, I would suggest rebooting the system and other things. In my use case, it took months to figure out how to make the timeshift USB and how to proceed. It is also possible to complete the next section using a completely different machine from the one used to create the initial Timeshift USB.
4. Execute the command sudo dd if=/dev/sdX of=/home/username/timeshift_img/NameBackupSDB.img status=progress.
Before you start, make sure you have enough free HDD space to accommodate the entire USB.
5. Launch 7z an SDBNameBackupCompressed from within the timeshift_img folder.7z NameBackupSDB.img -p -mhe=on -mx=3; mx=3 helps speed up the compression process by not attempting to optimize too much for file size; mhe=on is optional if you wish to encrypt the backup, which is a smart move if the system contained password files that you copied and are now stored within it during the original timeshift snapshot. Make sure you have enough HDD space before executing to accommodate a new 7z file that is roughly proportionate to the size of the image file. Observe that the compression is usually fairly good even though only the mx=3 compression level is used,
Timeshift snapshots can be compressed up to 50% of their original size, which is usually pretty good. This makes them far more compressible than pre-compressed media like picture or video files.
6. That 7z file is now completely portable, even though it can be very large. As long as the drive can handle BIG files (30GB or more for the 7z in my use case), you can save it on any drive, anyplace, and with any formatting (so NTFS formatted filesystems, but not FAT32 or exFAT).
Here's how to use it:
7. Start by installing your Linux OS fresh on a new system, ensure you install Timeshift within it if Timeshift isn't supplied by default (it is there by default in Mint 21.1, where I tested this). When installing make sure to match partition names, sizes and order to that of the original system you are cloning.
8. Once the fresh install is done and rebooted, so you don't have the live USB for it plugged in any more, copy the 7z file on to this system, uncompress it with 7z either via terminal or via the GUI archive extraction file program so as to create an extracted copy of NameBackupSDB.img on the new system.
9. Get an extra USB, larger than the one originally used for storing the snapshot, and use dd to write the img file to it. It is vital this be bigger than the original, it absolutely must not be smaller. If the original USB was 62GB*, even if only 30GB was used, you need a USB >62GB here even though only the first 30GB of the img file is used. I hear rumours that many drives keep a partition table at the very back end of the drive, so writing an overly large img file overwrites this and makes the drive useless until you've used gparted to wipe it and write a new partition table. I definitely found this the case, I had a 61555605504 byte original USB containing a 57GB timeshift partition plus free space, I initially tried to dd the img to a drive which had a real capacity of 61,530,439,680 bytes, dd gave no errors, but the USB created could not be read even though the only partition which mattered in the drive I had cloned from was only 57GB. I had to use Gparted to make a new partition table, which wiped what I had just dd'd on to it. I retried with a drive which read as 64GB actual capacity, all was fine this time.
sudo dd if=ExtractedNameBackupSDB.img of=/dev/sdc status=progress
sdc here is for the new USB ( >(original size) )you are writing to. If your original was, for example, 62GB and you can't find a truly 64GB USB, use a 128GB here.
*here you notice how important the diferences of advertised capacity and actual can be, many 64GB USBs are 62GB or 58GB... and you also note the irritaing differences of GB vs GiB (Giga vs Gibi, 1000 based vs 1024 based) and how you're never really sure which of Gb and GiB any given program displays figures in and a USB is advertised as
10. Safely eject the USB and restart the freshly installed system
11. When you have restarted, start timeshift on the new system and set it NOT to take automated (daily, or other timeframe) snapshots
11.5. Turn OFF screensaver settings, tell the PC not to go to sleep, or lock the screen
12. Now plug in the USB which you dd'd the img file to, in Timeshift's settings tell Timeshift to look to that USB's partition as the place for snapshots
13. Leaving timeshift's settings alone, proceed to restore the snapshot from that USB
13.5. At the "select target device" stage pick the paths for "/" and "/home" to be the relevant sdaY and sdaZ partitions of the internal HDD, leave "/boot" and "/boot/efi" as "Keep on root device". In bootloder options select the defaults (do "(Re)install Grub2 on:" and pick your SDA hard drive as the device, do not pick a partition, do not update initramfs, do "update grub menu").
14. Timeshift will do its stuff, and then put the PC in to a state where the whole screen is taken up by a listing of the files Timeshift is restoring
15. Then it will try to restart, and then it will crash
16. Power down the PC, and boot from he live USB again
17. With the live USB booted, mount the root partition of the internal HDD, and run
sudo caja
to create an elevated privilege file browser.
18. Browse to /etc/fstab on the internal HDD's root partition and open it in the elevated privilege text editor
19. Open the Live USB's "Disks" program
20. Edit /etc/fstab so each UUID it presently shows is replaced by the appropriate UUID seen in the Disks window, copy and paste from the Disks window to the /etc/fstab text file each UUID, or the EFI partition, root partition, home partition and any others. Note, if there were a way to work the other way round, telling the live system what UUIDs you want for each partition at an earlier point in time, I'd be interested in understanding that option too if anyone can tell me of ways to choose the UUID during installation of the OS to the HDD while booted from a Live USB.
21. Shut down the PC, remove the Live USB, now boot normally, log in, and open Timeshift again. Note that during pre-login the desktop background will match any custom one you have set, but after login it will still look like the default used on the fresh install.
22. At this point some parts of the snapshot have been restored, but some haven't, now we'll get them all restored
23. When you open Timeshift now it will have all the correct folder filters as were used when your original snapshot was made. Plug in your timeshift snapshot USB, select it as the device to restore from under "Location". When restoring from it use the same "select target device" settings as you did earlier on.
24. Allow it to restore, and go to the screen of scrolling file names again, and shut itself down
25. This time when it restarts it will crash again, you'll need to use the live USB again to make the /etc/fstab changes
26. With those changes made, the same way as before, shut down.
27. After that, remove the live USB, turn on the computer, and you'll have a fresh copy of the original system that was transferred using a fully portable 7z file 28. After that, you can utilize the USB that was used for the timeshift snapshot for regular file storage (only the larger later one, or both of them). In the event that you don't need to use up USB space with the timeshift snapshot, you can store the 7z file as a file on a sizable ntfs partition on any available data storage device. This allows you to generate a timeshift partition USB when needed.
I hope you found this useful.