Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Copying a Directory Structure to a new structure Post 79328 by vino on Wednesday 27th of July 2005 04:06:43 AM
Old 07-27-2005
Found from http://www.tldp.org/LDP/abs/html/spe...rs.html#BGLOOP

Quoting word-to-word from the above url.

Code:
redirection from/to stdin or stdout [dash].

(cd /source/directory && tar cf - . ) | (cd /dest/directory && tar xpvf -)
# Move entire file tree from one directory to another
# [courtesy Alan Cox <a.cox@swansea.ac.uk>, with a minor change]

# 1) cd /source/directory    Source directory, where the files to be moved are.
# 2) &&                     "And-list": if the 'cd' operation successful, then execute the next command.
# 3) tar cf - .              The 'c' option 'tar' archiving command creates a new archive,
#                            the 'f' (file) option, followed by '-' designates the target file as stdout,
#                            and do it in current directory tree ('.').
# 4) |                       Piped to...
# 5) ( ... )                 a subshell
# 6) cd /dest/directory      Change to the destination directory.
# 7) &&                     "And-list", as above
# 8) tar xpvf -              Unarchive ('x'), preserve ownership and file permissions ('p'),
#                            and send verbose messages to stdout ('v'),
#                            reading data from stdin ('f' followed by '-').
#
#                            Note that 'x' is a command, and 'p', 'v', 'f' are options.
# Whew!



# More elegant than, but equivalent to:
#   cd source/directory
#   tar cf - . | (cd ../dest/directory; tar xpvf -)
#
# cp -a /source/directory /dest/directory     also has same effect.

Vino
 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

MV files from one directory structure(multiple level) to other directory structure

Hi, I am trying to write a script that will move all the files from source directory structure(multiple levels might exist) to destination directory structure. If a sub folder is source doesnot exist in destination then I have to skip and goto next level. I also need to delete the files in... (4 Replies)
Discussion started by: srmadab
4 Replies

2. Shell Programming and Scripting

Need help in Directory Structure

I have writen the following code to show the dirctory structure. Can any body help me for using the recursive function in this code? echo "-(0)" echo "$HOME-(1)" cd ~ set * for i in `ls $HOME` do if then echo ".....${i}" cd... (5 Replies)
Discussion started by: murtaza
5 Replies

3. UNIX for Dummies Questions & Answers

Copying with directory structure

Hi, I need to copy a set of directories along with all sub directories and files from one unix box to another. Any ideas? cnfsed (4 Replies)
Discussion started by: Cnfsed
4 Replies

4. Shell Programming and Scripting

redirection and copying with same directory structure

Dear Experts, How can I solve this problem ? I want to redirect with having the same directory structure as in my input. for temp in `find ./CSV/ -name "*.v"` do fname = `basename $temp` ./script.sh $temp > ./out/$fname done But my problem here is all the... (3 Replies)
Discussion started by: user_prady
3 Replies

5. Programming

Search attributes in one structure using the values from another structure

Hello Groups I am trying to find out ways of comparing a value from a 'c' structure to a value in another 'C' structure. the 'C' structure can be a List or liked list as it contains lot many records. if we loop it in both the structures it is going to consume time. I am looking for a simple... (3 Replies)
Discussion started by: dhanamurthy
3 Replies

6. Shell Programming and Scripting

Copying a directory structure with the latest versions of files

Hello I have three directory structures for code releases. Each directory structure looks like this: bash-3.00$ ls -R | more .: Test_Release_1 Test_Release_2 Test_Release_3 ./Test_Release_1/dbcode: rp_online_import_srdp.pkb-1 srdp_ar_validation.pkb-1... (1 Reply)
Discussion started by: Glyn_Mo
1 Replies

7. UNIX for Dummies Questions & Answers

Help with copying specific parts of a file structure

Hello. I need help with copying part of a file structure to another directory while still keeping the structure. For example look below: ../folder1/sub1/txt.txt ../folder1/sub2/pic.png ../folder2/sub1/pic.png ../folder2/sub2/txt.txt So in this I would like to copy only the directories and... (3 Replies)
Discussion started by: the
3 Replies

8. Shell Programming and Scripting

Copying files to new dir structure.

I am trying to figure out a way to script copying specific files from one dir structure to another. I have a dir structure like this: dira/author 1/book 1/file a.epub /book 2/file b.epub /author 2/book 1/file c.epub /author 3/book 1/file d.epub /book 2/file... (2 Replies)
Discussion started by: arcanas
2 Replies

9. UNIX for Dummies Questions & Answers

copying the dir/subdir structure from one server to another?

Hi All, I want to copy the dir/subdir structure from SERVER-A to SERVER-B without copying all the files in each dir. Is it possible using SCP / SFTP command? For example, SERVER-A has following two dir/subdirectories and files under each subdir. ... (1 Reply)
Discussion started by: Hangman2
1 Replies

10. Shell Programming and Scripting

Copying files from various folders to similar folder structure in another location

Hi, I need to write a script the has to copy the files from folders and subfolders to the same folder structure located in another location. Ex: mainfolder1 file1,file2,file3 subfolder1(file1,etc) subfolder2(file1,etc) to another folder location of same folder structure. rsync is not... (7 Replies)
Discussion started by: Raji Perumal
7 Replies
RAIDFILE-CONFIG(8)						    Box Backup							RAIDFILE-CONFIG(8)

NAME
raidfile-config - Configure Box Backup's RAID files SYNOPSIS
raidfile-config config-dir blocksize dir1 [dir2 [dir3]] DESCRIPTION
raidfile-config creates a raidfile.conf file for Box Backup. This file holds information about the directories used to store backups in. Box Backup supports userland RAID, in a restricted RAID5 configuration, where 3 and only 3 'drives' are supported. You can read more about RAID5 (and other RAID-levels) here[1]. Parameters The parameters are as follows: config-dir The directory path where configuration files are located. Usually this is /etc/box. raidfile.conf will be written in this directory. blocksize The block size used for file storage in the system, in bytes. Using a multiple of the file system block size is a good strategy. Depending on the size of the files you will be backing up, this multiple varies. Of course it also depends on the native block size of your file system. dir1 The first directory in the built-in RAID array. dir2 The second directory in the built-in RAID array. If you are not using the built-in RAID functionality, this field should be ignored. You should not use the built-in RAID if you have a hardware RAID solution or if you're using another type of software RAID (like md on Linux). dir3 The third directory in the built-in RAID array. The same notes that apply to dir2 also apply to dir3. Note that there are currently no way to add multiple disk sets to the raidfile.conf file using command line tools, etc. See raidfile.conf(5) for details on adding more disks. BUGS
If you find a bug in Box Backup, and you want to let us know about it, join the mailing list[2], and send a description of the problem there. To report a bug, give us at least the following information: o The version of Box Backup you are running o The platform you are running on (hardware and OS), for both client and server. o If possible attach your config files (bbstored.conf, bbackupd.conf) to the bug report. o Also attach any log file output that helps shed light on the problem you are seeing. o And last but certainly not least, a description of what you are seeing, in as much detail as possible. FILES
raidfile-config generates the raidfile.conf(5) file. SEE ALSO
bbstored-config(8), bbstored.conf(5), raidfile.conf(5) AUTHORS
Ben Summers Per Thomsen James O'Gorman NOTES
1. here http://en.wikipedia.org/wiki/Redundant_array_of_independent_disks#RAID_5 2. mailing list http://lists.warhead.org.uk/mailman/listinfo/boxbackup Box Backup 0.11 10/28/2011 RAIDFILE-CONFIG(8)
All times are GMT -4. The time now is 08:59 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy