I want to make sure I am using the correct rsync
command on Linux. I do not want to run an rsync
and end up losing data as I am new to Linux and I have no backup now.
On Linux Mint, I want to backup /home/nasser/
and everything BELOW it to /home/BACKUP/
where I have a backup disk mounted.
Therefore, I'd like to end up with:
/home/nasser/file1
/home/nasser/file2
/home/nasser/A/file1
to
/home/BACKUP/file1
/home/BACKUP/file2
/home/BACKUP/A/file1
This should include all hidden files and directories preserving ownership and permissions. I made sure that /home/BACKUP/
is owned by me (user and group). (I just created it using sudo
and changed owner and group and mounted the backup disk at that point).
The command I plan to use is:
rsync -apvr --delete --chmod=ugo=rwX /home/nasser/ /home/BACKUP/
I will run this with my user account, not as root.
Is the above command correct to do what I want so I end up with duplicate files in all aspects? I plan to use this for regular backups, so I will use this command each time I want to make sure the backup is up to date.
For reference, these are the full steps I have performed to prepare for the backup.
- Bought a USB external disk. Come home and plugin into the PC
- Ran
dmesg
and saw [172850.144032] sd 9:0:0:0: >[sdc] [172850.170378] sd 9:0:0:0: >[sdc] Attached SCSI disk - Determined new disk is recognized at
/dev/sdc
Deleted existing partition and created new primary partition.
# sudo fdisk /dev/sdc
Command (m for help): d
Selected partition 1Command (m for help): n
Partition type:
p primary (0 primary, 0 extended, 4 free)
e extended
Select (default p): p
Partition number (1-4, default 1):Chose defaults to use the whole disk.
Command (m for help): w
...
Syncing disks.- Create ext4 filesystem
# sudo mkfs.ext4 /dev/sdc1
- Create mount point
# sudo mkdir /home/BACKUP
- Mount and assign everything to me, only needed to be done once
# sudo mount -t ext4 /dev/sdc1 /home/BACKUP/
# sudo chgrp -R nasser /home/BACKUP/
# sudo chown -R nasser /home/BACKUP/
--delete
?