Copying Folders in Ubuntu the correct way

I had to restore a Wordpress Backup on a test site and I was using simple cp command with the -r (Recursive) switch.

While setting up the blog, I noticed that some of the files are missing from the installation but were there in the source folder from where I was copying the files.

I re-ran the command but it was no good. The command which I was running is as below -
cp backup/wp-content destination/wp-content -r -v

The correct way to copy all of the files recursively in a folder and preserve the file attributes, I had to use the below command -
cp backup/wp-content/* destination/wp-content -pfr -v

Notice the additional /* after the source directory and the additional switches -pf

After running the above command, all of the files from the backup got copied successfully.

Source - https://askubuntu.com/a/312701

Pranav V Jituri

Read more posts by this author.

India

Subscribe to OMGDebugging!!!

Get the latest posts delivered right to your inbox.

or subscribe via RSS with Feedly!