Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Using CP to back up home directory

I use the following set of commands to backup my home directory on an HDD in a USB dock. I am using the drive in HDD to backup the home directories in my system and I thought this command would work to both do the initial copy and to later copy files that are new or updated.
[Carl@localhost ~]$ su

[root@localhost Carl]# cd /home

[root@localhost home]# cp -r -u -v Carl /run/media/Carl/036107cf-8650-421e-a46d-7f0e7df744ca

As I understand the man page for cp this should copy all files from my home directory Carl to directory Carl in the logical volume whose UUID is 036107cf-8650-421e-a46d-7f0e7df744ca. It should not copy a file if the time stamp of the corresponding file in the destination directory is later than that in the source because of the -u option nor should it ask me whether any files are to be replaced Y/N because I have not specified the -i option however as the following extract shows it is so asking.

cp: overwrite '/run/media/Carl/036107cf-8650-421e-a46d-7f0e7df744ca/Carl/.cache/gnome-software/3.24/upgrades/fedora.json'? n

cp: overwrite '/run/media/Carl/036107cf-8650-421e-a46d-7f0e7df744ca/Carl/.cache/gnome-software/3.24/firmware/firmware.xml.gz.asc'? n

cp: overwrite '/run/media/Carl/036107cf-8650-421e-a46d-7f0e7df744ca/Carl/.cache/gnome-software/3.24/firmware/firmware.xml.gz'? n

cp: overwrite '/run/media/Carl/036107cf-8650-421e-a46d-7f0e7df744ca/Carl/.cache/gnome-software/3.24/ratings/odrs.json'? n

cp: overwrite '/run/media/Carl/036107cf-8650-421e-a46d-7f0e7df744ca/Carl/.cache/gnome-software/3.24/extensions/gnome.json'? n

cp: overwrite '/run/media/Carl/036107cf-8650-421e-a46d-7f0e7df744ca/Carl/.cache/tracker/locale-for-miner-user-guides.txt'? ^C

And since my home directory contains an enormous number of files replying Y or N is impractical especially since I do not know why the command is asking the question.

If cp cannot do what I want is there another command that will?