Views:
683β
Votes: 5β
β
Solution
Tags:
hard-drive
backup
external-hdd
Link:
π See Original Answer on Ask Ubuntu β§ π
URL:
https://askubuntu.com/q/1032562
Title:
Exact Copy (Backup) of Full Directory Tree To External (Backup) Drive
ID:
/2018/05/05/Exact-Copy-_Backup_-of-Full-Directory-Tree-To-External-_Backup_-Drive
Created:
May 5, 2018
Upload:
September 15, 2024
Layout: post
TOC:
false
Navigation: false
Copy to clipboard: false
Most backup programs compress data to specialized backup archives. Special search tools are required to locate files withing backup archives and special commands must be used to retrieve backup files.
If you only want an exact copy of files consider the rsync
command.
Borrowing from this answer: Bash script to clone Ubuntu to new partition for testing 18.04 LTS upgrade here is how to clone a full 16.04 installation:
rsync -haxAX --stats --delete --info=progress2 --info=name0 /* "$TargetMnt" \
--exclude={/dev/*,/proc/*,/sys/*,/tmp/*,/run/*,/mnt/*,/media/*,/lost+found}
Some notable comments about parameters:
--stats
gives information on files added, changed and deleted from the clone (called backup in your case).--delete
instructs rsync to delete files in the clone that no longer exist in the source directory.info=progress2
gives a modern looking progress display whilst cloning directories.--info=name0
prevents every single filename from being displayed as it is being copied. This gives less screen clutter but you may want to omit this parameter./*
tellsrsync
where to start synchronizing files. In this example itβs the root directory but you want to change it to/media/user1/DATA4/FolderA
."$TargetMnt"
tellsrscync
where to clone to. In your case change it to"/media/ivan/Seagate Backup Plus Drive/FolderA"
. The double quotes are important because your directory names contain spaces in them.- The second line starting with
--exclude={/dev/*
you donβt need at all because these directories arenβt in the list. Donβt use this line and drop the line continuation character\
at the end of the first line.
As with all backup scenarios always test the backups to make sure all files are there and contain the appropriate information.