LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
Search this Thread
Old 09-13-2008, 01:03 AM   #16
Mr. C.
Senior Member
 
Registered: Jun 2008
Posts: 2,529

Rep: Reputation: 59

Well, time to learn! Be sure to read man rsync.

Here's an example (simplified for brevity):

Code:
$ cat mkdata 
#!/bin/bash

for network in {A..C} ; do
    for station in {1..3} ; do   
        for channel in {1..3} ; do   
            dir=data/$network/N${network}_S${station}/N${network}_S${station}_C${channel}
            mkdir -p $dir
            for file in {1..3} ; do   
                touch $dir/file${file}
            done
        done
    done
done
Now, let's make the data:

Code:
$ ./mkdata 
$ ls -R data
A/ B/ C/

data/A:
NA_S1/ NA_S2/ NA_S3/

data/A/NA_S1:
NA_S1_C1/ NA_S1_C2/ NA_S1_C3/

data/A/NA_S1/NA_S1_C1:
file1  file2  file3

data/A/NA_S1/NA_S1_C2:
file1  file2  file3

data/A/NA_S1/NA_S1_C3:
file1  file2  file3

data/A/NA_S2:
NA_S2_C1/ NA_S2_C2/ NA_S2_C3/

data/A/NA_S2/NA_S2_C1:
file1  file2  file3

data/A/NA_S2/NA_S2_C2:
file1  file2  file3

data/A/NA_S2/NA_S2_C3:
file1  file2  file3

data/A/NA_S3:
NA_S3_C1/ NA_S3_C2/ NA_S3_C3/

data/A/NA_S3/NA_S3_C1:
file1  file2  file3

data/A/NA_S3/NA_S3_C2:
file1  file2  file3

data/A/NA_S3/NA_S3_C3:
file1  file2  file3

data/B:
NB_S1/ NB_S2/ NB_S3/

data/B/NB_S1:
NB_S1_C1/ NB_S1_C2/ NB_S1_C3/

data/B/NB_S1/NB_S1_C1:
file1  file2  file3

data/B/NB_S1/NB_S1_C2:
file1  file2  file3

data/B/NB_S1/NB_S1_C3:
file1  file2  file3

data/B/NB_S2:
NB_S2_C1/ NB_S2_C2/ NB_S2_C3/

data/B/NB_S2/NB_S2_C1:
file1  file2  file3

data/B/NB_S2/NB_S2_C2:
file1  file2  file3

data/B/NB_S2/NB_S2_C3:
file1  file2  file3

data/B/NB_S3:
NB_S3_C1/ NB_S3_C2/ NB_S3_C3/

data/B/NB_S3/NB_S3_C1:
file1  file2  file3

data/B/NB_S3/NB_S3_C2:
file1  file2  file3

data/B/NB_S3/NB_S3_C3:
file1  file2  file3

data/C:
NC_S1/ NC_S2/ NC_S3/

data/C/NC_S1:
NC_S1_C1/ NC_S1_C2/ NC_S1_C3/

data/C/NC_S1/NC_S1_C1:
file1  file2  file3

data/C/NC_S1/NC_S1_C2:
file1  file2  file3

data/C/NC_S1/NC_S1_C3:
file1  file2  file3

data/C/NC_S2:
NC_S2_C1/ NC_S2_C2/ NC_S2_C3/

data/C/NC_S2/NC_S2_C1:
file1  file2  file3

data/C/NC_S2/NC_S2_C2:
file1  file2  file3

data/C/NC_S2/NC_S2_C3:
file1  file2  file3

data/C/NC_S3:
NC_S3_C1/ NC_S3_C2/ NC_S3_C3/

data/C/NC_S3/NC_S3_C1:
file1  file2  file3

data/C/NC_S3/NC_S3_C2:
file1  file2  file3

data/C/NC_S3/NC_S3_C3:
file1  file2  file3
Now, let's create our backup:
Code:
$ rsync -av data/ databkp/
sending incremental file list
created directory databkp
./
A/
A/NA_S1/
A/NA_S1/NA_S1_C1/
A/NA_S1/NA_S1_C1/file1
A/NA_S1/NA_S1_C1/file2
A/NA_S1/NA_S1_C1/file3
A/NA_S1/NA_S1_C2/
A/NA_S1/NA_S1_C2/file1
A/NA_S1/NA_S1_C2/file2
A/NA_S1/NA_S1_C2/file3
A/NA_S1/NA_S1_C3/
A/NA_S1/NA_S1_C3/file1
A/NA_S1/NA_S1_C3/file2
A/NA_S1/NA_S1_C3/file3
A/NA_S1/NA_S1_C3/file6
A/NA_S2/
A/NA_S2/NA_S2_C1/
A/NA_S2/NA_S2_C1/file1
A/NA_S2/NA_S2_C1/file2
A/NA_S2/NA_S2_C1/file3
A/NA_S2/NA_S2_C2/
A/NA_S2/NA_S2_C2/file1
A/NA_S2/NA_S2_C2/file2
A/NA_S2/NA_S2_C2/file3
A/NA_S2/NA_S2_C3/
A/NA_S2/NA_S2_C3/file1
A/NA_S2/NA_S2_C3/file2
A/NA_S2/NA_S2_C3/file3
A/NA_S3/
A/NA_S3/NA_S3_C1/
A/NA_S3/NA_S3_C1/file1
A/NA_S3/NA_S3_C1/file2
A/NA_S3/NA_S3_C1/file3
A/NA_S3/NA_S3_C2/
A/NA_S3/NA_S3_C2/file1
A/NA_S3/NA_S3_C2/file2
A/NA_S3/NA_S3_C2/file3
A/NA_S3/NA_S3_C3/
A/NA_S3/NA_S3_C3/file1
A/NA_S3/NA_S3_C3/file2
A/NA_S3/NA_S3_C3/file3
B/
B/NB_S1/
B/NB_S1/NB_S1_C1/
B/NB_S1/NB_S1_C1/file1
B/NB_S1/NB_S1_C1/file2
B/NB_S1/NB_S1_C1/file3
B/NB_S1/NB_S1_C2/
B/NB_S1/NB_S1_C2/file1
B/NB_S1/NB_S1_C2/file2
B/NB_S1/NB_S1_C2/file3
B/NB_S1/NB_S1_C3/
B/NB_S1/NB_S1_C3/file1
B/NB_S1/NB_S1_C3/file2
B/NB_S1/NB_S1_C3/file3
B/NB_S2/
B/NB_S2/NB_S2_C1/
B/NB_S2/NB_S2_C1/file1
B/NB_S2/NB_S2_C1/file2
B/NB_S2/NB_S2_C1/file3
B/NB_S2/NB_S2_C2/
B/NB_S2/NB_S2_C2/file1
B/NB_S2/NB_S2_C2/file2
B/NB_S2/NB_S2_C2/file3
B/NB_S2/NB_S2_C3/
B/NB_S2/NB_S2_C3/file1
B/NB_S2/NB_S2_C3/file2
B/NB_S2/NB_S2_C3/file3
B/NB_S3/
B/NB_S3/NB_S3_C1/
B/NB_S3/NB_S3_C1/file1
B/NB_S3/NB_S3_C1/file2
B/NB_S3/NB_S3_C1/file3
B/NB_S3/NB_S3_C2/
B/NB_S3/NB_S3_C2/file1
B/NB_S3/NB_S3_C2/file2
B/NB_S3/NB_S3_C2/file3
B/NB_S3/NB_S3_C3/
B/NB_S3/NB_S3_C3/file1
B/NB_S3/NB_S3_C3/file2
B/NB_S3/NB_S3_C3/file3
C/
C/NC_S1/
C/NC_S1/NC_S1_C1/
C/NC_S1/NC_S1_C1/file1
C/NC_S1/NC_S1_C1/file2
C/NC_S1/NC_S1_C1/file3
C/NC_S1/NC_S1_C2/
C/NC_S1/NC_S1_C2/file1
C/NC_S1/NC_S1_C2/file2
C/NC_S1/NC_S1_C2/file3
C/NC_S1/NC_S1_C3/
C/NC_S1/NC_S1_C3/file1
C/NC_S1/NC_S1_C3/file2
C/NC_S1/NC_S1_C3/file3
C/NC_S2/
C/NC_S2/NC_S2_C1/
C/NC_S2/NC_S2_C1/file1
C/NC_S2/NC_S2_C1/file2
C/NC_S2/NC_S2_C1/file3
C/NC_S2/NC_S2_C2/
C/NC_S2/NC_S2_C2/file1
C/NC_S2/NC_S2_C2/file2
C/NC_S2/NC_S2_C2/file3
C/NC_S2/NC_S2_C3/
C/NC_S2/NC_S2_C3/file1
C/NC_S2/NC_S2_C3/file2
C/NC_S2/NC_S2_C3/file3
C/NC_S3/
C/NC_S3/NC_S3_C1/
C/NC_S3/NC_S3_C1/file1
C/NC_S3/NC_S3_C1/file2
C/NC_S3/NC_S3_C1/file3
C/NC_S3/NC_S3_C2/
C/NC_S3/NC_S3_C2/file1
C/NC_S3/NC_S3_C2/file2
C/NC_S3/NC_S3_C2/file3
C/NC_S3/NC_S3_C3/
C/NC_S3/NC_S3_C3/file1
C/NC_S3/NC_S3_C3/file2
C/NC_S3/NC_S3_C3/file3

sent 4743 bytes  received 1729 bytes  12944.00 bytes/sec
total size is 0  speedup is 0.00
Now let's create a new file somewhere in the directory tree representing your new daily file(s), and run rsync again:

Code:
$ rsync -av data/ databkp/         
sending incremental file list
A/NA_S1/NA_S1_C3/file6

sent 1464 bytes  received 70 bytes  3068.00 bytes/sec
total size is 0  speedup is 0.00
Good, it copied only the new file. What happens if we run rsync once again, without any new files or file changes:
Code:
$ rsync -av data/ databkp/
sending incremental file list

sent 1425 bytes  received 51 bytes  2952.00 bytes/sec
total size is 0  speedup is 0.00
Ok, good, nothing done. Let's look at our final backup directory:

Code:
$ ls -R databkp/
A/ B/ C/

databkp/A:
NA_S1/ NA_S2/ NA_S3/

databkp/A/NA_S1:
NA_S1_C1/ NA_S1_C2/ NA_S1_C3/

databkp/A/NA_S1/NA_S1_C1:
file1  file2  file3

databkp/A/NA_S1/NA_S1_C2:
file1  file2  file3

databkp/A/NA_S1/NA_S1_C3:
file1  file2  file3  file6

databkp/A/NA_S2:
NA_S2_C1/ NA_S2_C2/ NA_S2_C3/

databkp/A/NA_S2/NA_S2_C1:
file1  file2  file3

databkp/A/NA_S2/NA_S2_C2:
file1  file2  file3

databkp/A/NA_S2/NA_S2_C3:
file1  file2  file3

databkp/A/NA_S3:
NA_S3_C1/ NA_S3_C2/ NA_S3_C3/

databkp/A/NA_S3/NA_S3_C1:
file1  file2  file3

databkp/A/NA_S3/NA_S3_C2:
file1  file2  file3

databkp/A/NA_S3/NA_S3_C3:
file1  file2  file3

databkp/B:
NB_S1/ NB_S2/ NB_S3/

databkp/B/NB_S1:
NB_S1_C1/ NB_S1_C2/ NB_S1_C3/

databkp/B/NB_S1/NB_S1_C1:
file1  file2  file3

databkp/B/NB_S1/NB_S1_C2:
file1  file2  file3

databkp/B/NB_S1/NB_S1_C3:
file1  file2  file3

databkp/B/NB_S2:
NB_S2_C1/ NB_S2_C2/ NB_S2_C3/

databkp/B/NB_S2/NB_S2_C1:
file1  file2  file3

databkp/B/NB_S2/NB_S2_C2:
file1  file2  file3

databkp/B/NB_S2/NB_S2_C3:
file1  file2  file3

databkp/B/NB_S3:
NB_S3_C1/ NB_S3_C2/ NB_S3_C3/

databkp/B/NB_S3/NB_S3_C1:
file1  file2  file3

databkp/B/NB_S3/NB_S3_C2:
file1  file2  file3

databkp/B/NB_S3/NB_S3_C3:
file1  file2  file3

databkp/C:
NC_S1/ NC_S2/ NC_S3/

databkp/C/NC_S1:
NC_S1_C1/ NC_S1_C2/ NC_S1_C3/

databkp/C/NC_S1/NC_S1_C1:
file1  file2  file3

databkp/C/NC_S1/NC_S1_C2:
file1  file2  file3

databkp/C/NC_S1/NC_S1_C3:
file1  file2  file3

databkp/C/NC_S2:
NC_S2_C1/ NC_S2_C2/ NC_S2_C3/

databkp/C/NC_S2/NC_S2_C1:
file1  file2  file3

databkp/C/NC_S2/NC_S2_C2:
file1  file2  file3

databkp/C/NC_S2/NC_S2_C3:
file1  file2  file3

databkp/C/NC_S3:
NC_S3_C1/ NC_S3_C2/ NC_S3_C3/

databkp/C/NC_S3/NC_S3_C1:
file1  file2  file3

databkp/C/NC_S3/NC_S3_C2:
file1  file2  file3

databkp/C/NC_S3/NC_S3_C3:
file1  file2  file3
That's it. Give it a try using the mkdata script above, changing sequence values and directory or filenames as you see fit.
 
  


Reply

Tags
command, cp, directories


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Omitting directories... WHY??? vonedaddy Linux - Newbie 4 11-23-2007 01:44 AM
Omitting Directory Error carlosinfl Linux - General 3 03-27-2007 05:21 PM
omitting space in shell script Fond_of_Opensource Linux - Newbie 10 11-18-2006 10:18 AM
cp: omitting error jsolanky Linux - Software 10 11-28-2004 10:09 AM
formating console output (omitting parts you do not want) bpk Linux - Newbie 6 06-10-2004 08:32 PM


All times are GMT -5. The time now is 06:47 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration