<- Back
#backup
#copy
rsync
Copy directory and preserve as much info as possible
Copy (archive)
sudo rsync -avAXh --info=progress2 --info=name0 /mnt/source/ /mnt/target/
Copy as the current user
sudo rsync -rltvXh --info=progress2 --info=name0 /mnt/source/ /mnt/target/
Optional extra arguments
-n:--dry-run-i:--itemize-changes-z:--compress-P:--partial(continues files)-H:--hard-links(preserve hard links)--ignore-existing/--ignore-non-existing(=--existing)--rsync-path="sudo rsync": Use sudo to access root files
Itemize Changes
https://stackoverflow.com/questions/4493525/what-does-f-mean-in-rsync-logs
https://dev.to/alexisayenko/understanding-rsync-itemize-changes-5fgi
The log output can be interpreted like this:
>f.st……
> - the item is received
f - it is a regular file
s - the file size is different
t - the time stamp is different
.d..t……
. - the item is not being updated (though it might have attributes
that are being modified)
d - it is a directory
t - the time stamp is different
>f+++++++++
> - the item is received
f - a regular file
+++++++++ - this is a newly created item
For copying system drives
Replicate partition table
Recreate all partitions manually.
Mount both drives (old and new) and copy files
Use rsync to copy files.
Note:
for system drives, copying /dev, /proc, /sys directories should be avoided: either exclude them with –exclude or do this from a live environment.
–exclude={“/dev/”,”/proc/”,”/sys/”,”/tmp/”,”/run/”,”/mnt/”,”/media/*”,”lost+found”}
Reinstall GRUB
sudo mount --bind /dev /mnt/target/dev
sudo mount --bind /proc /mnt/target/proc
sudo mount --bind /sys /mnt/target/sys
sudo chroot /mnt/target
grub-install /dev/sdY
update-grub
Update /etc/fstab if needed
- Check
sudo blkidto see new UUIDs. - Edit
/mnt/target/etc/fstabto match the new partition UUIDs so it boots correctly.