]> www.wagner.pp.ru Git - oss/restore.git/blob - README.md
4c8216152523b129a30c9189ecb75e405586c8e3
[oss/restore.git] / README.md
1 Restoration script for full linux backup
2 ========================================
3
4 Prepare for backups
5 -------------------
6
7 Before you'll be able to restore your system from backup, you have to do
8 backups.
9
10 1. Get an USB thumb drive or external HDD big enough to hold entire
11    content of our notebook's SSD.
12 2. Install [gparted-live](https://gparted.org/livecd.php) into beginning of this disk
13 3. Format rest of this disk (gparted would take no more than half of GB
14 at the beginning) as ext4 system
15 4. Install [rsnapshot](https://rsnapshot.org/) on your machine and set up it to make backup into
16    ```
17    /media/${your name}/${label of your USB partition}/${hostname}
18    ```
19    Or whereever your desktop enviroment mountes removable disks.
20
21    If you have big usb HDD and several notebooks, you can backup all of
22    them on one medium.
23    You should backup everything including /boot/efi, although you can
24    omit mozilla cache and other thinks which are likely to change during
25    backup.
26
27 5. Do first backup. Do:
28    ```
29    echo p |fdisk /dev/nvme0n1 > partitions.layout  
30    ```
31
32    copy restore script into root of your backup partition.
33
34 Do backup regularly
35 -------------------
36
37 Don't forget to insert this USB drive into your notebook and run 
38 rsnapshot with appropraite argument as root on regular basis.
39
40 Use alpha/beta/gamma modes of rsnapshots, so you'll store daily backups
41 for last week, weekly ones for last month and several monthly ones.
42
43 Restore old files occasionaly
44 -----------------------------
45
46 Sometimes you'll find out that you have incedently removed or modified
47 some file. You can than plug your backup drive in and get yesterday's or
48 week ago copy.
49
50 When disaster happens
51 ---------------------
52
53 When your SSD drive dies, or have been irrepairable  wiped out,
54 or hit by trojan or cryptolocker so it is easier to wipe out then do 
55 anythin else:
56
57 1. Repair the hardware
58 2. Insert your backup drive in USB port and boot from it. Mount your
59    second partition under, say `/mnt`
60 3. From parted-live GUI create neccessary partitions. You can consult
61    partitions.layout file which you have created while preparing backup.
62    Don't forget create vfat partion for `/boot/efi`, if you are using uefi
63    boot.
64 4. Mount newly created root partition under, say `/target`
65    and if you unse separate partitions for `/home`, `/var` or anything else,
66    mount them on `/target/home`, `/target/var` etc.
67    Don't forget to mount `/target/boot/efi`
68 5. Cd to `/mnt` and run 
69     ```
70     restore /target
71         ```
72     IF you keep backup for several
73     compiters on one disk or want to restore not the latest daily backup,
74     specify backup directory
75     
76         ```
77     restore mynote/beta.1 /target
78         ```
79 6. Reboot and enjoy.
80
81 Other uses
82 ----------
83
84 You can use this restoration procedure when you are upgrading your main
85 SSD - no need to search for USB SATA or USB NVME controller to copy data
86 from old disk. That is why we don't create partitions from script. User
87 may want to rearrange partition layout or just restore system on bigger
88 drive.