I am trying to copy a folder while preserving ownership. When I use the command:
sudo cp -R -p /var/lib/mysql /newpath
the files copy but the ownership changes (my username becomes the owner on the new files) and I get an error message saying that cp: failed to preserve ownership for '/newpath/subdirectory' : Operation not permitted
for each subdirectory and file in the copied folder. Trying to switch back ownership on the copied files produces the same error (with chown in the place of cp).
sudo chown -R username:group /newpath
I am trying to copy a mysql data directory folder to my second hard drive in such a way that I can then use it as the database directory for the mysql server (username mysql) with webmin.
lsattr /newpath
). How is it mounted? – steeldriver May 5 '14 at 23:09