10

Making a quick backup:

root@guilmon:/mnt/backup/guilmon/home# cp -uvfrx --preserve=all /home/rena/ .

The output is surprising - some files are said to be removed!

removed ‘./rena/dev/lua/conkybitcoin/conkybitcoin.lua’

The files being removed seem to be random and haven't changed. Why does it say it's removing them? Even stranger, it doesn't appear to have actually removed that file (nor the source). What's going on?

15

cp with the --force and --verbose options (-f and -v in your command line) outputs the "removed" message whenever it removes a destination file before copying it. (--force tells cp to remove a destination file if it can't be opened, before trying the copy again.)

In your example, it means that ./rena/dev/lua/conkybitcoin/conkybitcoin.lua couldn't be opened for writing, so cp removed it and copied it again from /home/rena.

  • I see. So then the question is why it couldn't be opened... – Rena May 23 '15 at 19:12
  • Is it read-only? – Stephen Kitt May 23 '15 at 19:13
  • 1
    The real question is, was it (the pre-existing file in the destination directory) read-only before you ran the cp command? – G-Man May 23 '15 at 22:11
  • Both are mode 0644, and I ran cp as root, so should be fine there. Existing destination should have been fine too since I used the same command to copy all of /home to the backup disk yesterday after creating a fresh, empty filesystem on it. btrfs scrub reports no errors on either disk. – Rena May 23 '15 at 23:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.