Weird problem with cp command on a Synology


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Weird problem with cp command on a Synology
# 1  
Old 02-24-2011
Weird problem with cp command on a Synology

Hi.

First post, and Linux newbie, so maybe I'm missing something obvious:

I have a Synology NAS that is run by a Linux distribution (which?). I have had an external hard drive connected to the NAS for making backups using Synology's backup application Time Backup.

Time Backup is based on rsync, so it creates incremental backups with all identical files being replaced by symbolic links.

I had to send the external hard drive in for repair, but before I did, I wanted to make a copy of all the backup data, so I wouldn't lose all my backup versions if they had to format the drive.

I found out, however, that when I tried to copy the drive, all the symbolic links were being followed, so I quickly used up all the space on the drive I wanted to copy the data to.

After a little research I found a solution with this command, run from a terminal (I SSH into the NAS using WinSCP):

Code:
cp -R -P /volumeSATA/satashare/TimeBackup /volume1/public

This effective copied all the backup data, including all the symbolic links and not the files that they pointed to, to a folder 'TimeBackup' in the directory 'public'.

Now I have my external hard disk back, and sure enough, it's been formatted, so now I need to put the backup data back on the drive.

This should be easy enough, I just need to switch the two locations from the command above around, and everything should be copied back - but no! When I run this command:

Code:
cp -R -P /volume1/public/TimeBackup /volumeSATA/satashare

the data starts copying alright, BUT the symbolic links are followed, so the disk fills up.

Am I doing something wrong? Shouldn't the "-P" parameter prevent the links from being followed??

---------- Post updated at 10:01 PM ---------- Previous update was at 05:34 PM ----------

Quote:
Originally Posted by Pokersut
Time Backup is based on rsync, so it creates incremental backups with all identical files being replaced by symbolic links.
Correction: It uses hard links, not symbolic links!
# 2  
Old 02-24-2011
cp makes no guarantees about hard links. I would not automatically expect that to work. I gave it a try on RedHat:
Code:
$ cd /tmp
$ mkdir one
$ touch one/file1
$ ln one/file1 one/file2
$ cp -R -P one two
$ ls -li one
total 0
3507036 -rw-r--r-- 2 xxxxx unixadm 0 Feb 24 16:28 file1
3507036 -rw-r--r-- 2 xxxxx unixadm 0 Feb 24 16:28 file2
$ ls -li two
total 0
3507039 -rw-r--r-- 1 xxxxx unixadm 0 Feb 24 16:29 file1
3507038 -rw-r--r-- 1 xxxxx unixadm 0 Feb 24 16:29 file2
$

I have one file with two hard links in directory "one" and I have two files in directory "two". You can just stat a file and discover that it is a symlink. To discover duplicate hard links you need to maintain a list of every inode you encounter. And you need to detect when you cross a mounted file system too since each filesystem can have an inode numbered 3507036.
This User Gave Thanks to Perderabo For This Post:
# 3  
Old 02-25-2011
Please clarify whether "symbolic links" means "hard links" or "soft links" by posting a directory listing of two linked files with full directory details:
Code:
ls -lisad original_file
ls -lisad link_to_file

Then again after the files have been copied with your "cp" command.
# 4  
Old 02-25-2011
Quote:
Originally Posted by methyl
Please clarify whether "symbolic links" means "hard links" or "soft links" by posting a directory listing of two linked files with full directory details:
Code:
ls -lisad original_file
ls -lisad link_to_file

Then again after the files have been copied with your "cp" command.
They are hard links - but I managed to solve the problem myself! This did the trick:

rsync -r -H /volume1/public/TimeBackup /volumeSATA/satashare

It took a bit of time to move the data (16-18 hours), but now it's done, and my external drive is now an exact clone of the one I sent in.

Thanks for your replies, anyway!
This User Gave Thanks to Pokersut For This Post:
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Weird awk problem

Hi, I have a simple awk script: BEGIN{} { $a=$2-$1; print $a } END{if(NR==0){ print "0" } } to which I provide the following input 2.9 14 22.2 27 (4 Replies)
Discussion started by: jamie_123
4 Replies

2. UNIX for Dummies Questions & Answers

Weird problem with join command

I have a weird issue going on with the join command... I have two files I am trying to join...here is a line from each file with the important parts marked in red: file1: /groupspace/ccops/cmis/bauwkrcn/commsamp_20140315.txt,1 file2:... (3 Replies)
Discussion started by: dbiggied
3 Replies

3. Programming

A weird problem with POSIX function

Hi all, Sorry for the title because I didn't find a proper name for it. My question is about POSIX functions, such as timer_create(), mq_open() and pthread_create(). void test_queue() { struct mq_attr attr; attr.mq_maxmsg = 10; attr.mq_msgsize = 64; mq_unlink("/my_test_queue");... (6 Replies)
Discussion started by: bus147
6 Replies

4. Shell Programming and Scripting

awk weird problem.

awk 'BEGIN{print 1.2.3.4}' 1.20.30.4 Can anyone explain why has extra "0" in the IP address? (3 Replies)
Discussion started by: newoz
3 Replies

5. Infrastructure Monitoring

Weird dependency problem!

Hi, I want to install net-snmp-devel package but i have following dependecy problem. It's very odd, i don't get it. One of packages is depended on the other one, the other one is depended on the previous one as well. :S :S Could you help me please? Here are the steps: # ls -l total... (4 Replies)
Discussion started by: oduth
4 Replies

6. UNIX for Advanced & Expert Users

Really weird delete problem

Hi, I've Ubuntu 8.04, and it has some files that I just cannot delete. I've tried everything, inode, fsck etc. Here is what the ls -li outputs root@ubuntu:/home/luser/.local/share/Trash/files/junk# ls -l ls: cannot access TRUNK_: No such file or directory ls: cannot access 2006_output.mv:... (11 Replies)
Discussion started by: nitin
11 Replies

7. Shell Programming and Scripting

Weird Variable Evaluation problem

Hi Guys.. I have a script which is: #!/bin/ksh for file in `grep qtc $PIC_SHS/xback00.ksh |cut -d"=" -f2` do ls $file cp $file ./ done output of grep is $ grep qtc $PIC_SHS/xback00.ksh |cut -d"=" -f2 $PIC_BIN/XPBACKRC0.qtc $PIC_BIN/XPBACK000.qtc $PIC_BIN/XPBACKSS0.qtc... (2 Replies)
Discussion started by: vamsi.coe
2 Replies

8. Shell Programming and Scripting

Weird date difference problem

I am trying to find the difference in days between 2 dates. I have to extract the 1st date from a filename, which i did using the awk command. I have to compare this date to today's date and if the difference is greater than 30 days, do something, else do something else. This is what i wrote... (22 Replies)
Discussion started by: meeraKh
22 Replies

9. Solaris

Weird crontab problem

Greetings To All! I am running Solaris 10 in a sparc environment. Here is the deal: In /var/spool/cron/crontabs, there is a cron user named "sys". If I do a crontab -l sys, it returns: # 0 * * * 0-6 /usr/lib/sa/sa1 # 20,40 8-17 * * 1-5 /usr/lib/sa/sa1 # 5 18 * * 1-5 /usr/lib/sa/sa2... (8 Replies)
Discussion started by: RobSand
8 Replies

10. UNIX for Dummies Questions & Answers

Weird Problem???

I have a problem I don't understand... I am trying to declare a variable, and then output the results of that variable, couldn't be simpler #!/bin/ksh VAR='Oranges' if then echo "Found Lemons" elif then echo "Found Oranges" fi The output shouold clearly be "Found Oranges", but... (2 Replies)
Discussion started by: danhodges99
2 Replies
Login or Register to Ask a Question