3
$ ls -la /tee/mysql
total 28675
drwxrwxrwx 1 root root      448 Jun 25 13:52 .
drwxrwxrwx 1 root root     2896 Jun 25 12:12 ..
-rwxrwxrwx 1 root root 18874368 Jun 25 13:19 ibdata1
-rwxrwxrwx 1 root root  5242880 Jun 25 13:52 ib_logfile0
-rwxrwxrwx 1 root root  5242880 Jun 25 13:19 ib_logfile1
drwxrwxrwx 1 root root      984 Jun 25 11:23 mysql
$ sudo ls -la /var/lib/mysql.old
total 88887336
drwx------  6 mysql mysql        4096 Jun 25 11:23 .
drwxr-xr-x 41 root  root         4096 Jun 25 13:15 ..
-rw-r--r--  1 mysql mysql           0 Apr 26 11:10 debian-5.5.flag
-rw-rw----  1 mysql mysql 91010105344 Jun 25 12:12 ibdata1
-rw-rw----  1 mysql mysql     5242880 Jun 25 12:12 ib_logfile0
-rw-rw----  1 mysql mysql     5242880 Jun 25 11:23 ib_logfile1
drwx------  2 mysql mysql        4096 Jun 20 17:22 m
drwx------  2 mysql mysql        4096 Apr 26 11:10 mysql
-rw-rw----  1 mysql mysql           6 Apr 25 06:40 mysql_upgrade_info
drwx------  2 mysql mysql        4096 Apr 26 11:10 performance_schema
drwx------  2 mysql mysql        4096 Feb 12 16:22 test
$ sudo cp -p -f -r /var/lib/mysql.old /tee/mysql
$ sudo ls -la /tee/mysql
total 28676
drwxrwxrwx 1 root root      552 Jun 25 14:09 .
drwxrwxrwx 1 root root     2896 Jun 25 12:12 ..
-rwxrwxrwx 1 root root 18874368 Jun 25 13:19 ibdata1
-rwxrwxrwx 1 root root  5242880 Jun 25 13:52 ib_logfile0
-rwxrwxrwx 1 root root  5242880 Jun 25 13:19 ib_logfile1
drwxrwxrwx 1 root root        0 Jun 25 11:23 mysql
drwxrwxrwx 1 root root      984 Jun 25 11:23 mysql.old
$ df |grep tee # blocks used available percent-used mounted
/dev/sda1                       2930232316 186242116 2743990200   7% /tee
$ cd
$ touch test
$ ls test*
test
$ cp -n test test2 # test whether cp works at all
$ ls test*
test  test2

Why doesn't sudo cp -p -f -r /var/lib/mysql.old /tee/mysql copy the entire contents of mysql.old into mysql?

4

Actually, you copied the mysql.old directory into /tee/mysql:

cp

But I think that this is not what you wished. I assume that maybe you wished to copy all subdirectories and files from mysql.old directory to /tee/mysql. To do so, use the following command:

sudo cp -p -f -r /var/lib/mysql.old/* /tee/mysql

So, don't forget about /* at the end of the source directory. Generally, for this purpose, use:

cp -pfr <SourceDirectory>/* <DestinationDirectory>

See man cp for more about the cp command.

0

I just tried the command that you used, and it worked. But go ahead and try this one:

sudo cp -r -fHip -- <Source_Directory> <Target_Directory>

Here is what I did:

sudo cp -r -fHip -- /home/mitch/Test/* /home/mitch/test1

and it copied all files and folders to the destination.

  • I don't see anything about -- in the man page. Can you clarify what it does, please? Also, the example you give includes a trailing /* on the source directory whereas the normative code just above it does not. – msh210 Jun 25 '13 at 23:09
  • ...but sudo cp -r -fHip -- /var/lib/mysql.old /tee/mysql worked (on that directory. It looks as though I'll have to do subdirectories separately). – msh210 Jun 26 '13 at 5:27

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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