Home » Questions » Computers [ Ask a new question ]

How do I replicate the directory structure to a remote Linux server?

How do I replicate the directory structure to a remote Linux server?

I want to replicate a complex directory structure from one Linux server to another remote server start at a certain sub-directory.

Asked by: Guest | Views: 346
Total answers/comments: 2
bert [Entry]

"You can combine find and cpio to make a list of subdirectories from the current working directory thus:

find . -type d -print | cpio -oO dirs.cpio

To rebuild that directory hierarchy on the remote machine, copy over the dirs.cpio file to the desired location and run:

cpio -iI dirs.cpio"
bert [Entry]

"Use rsync to recursively copy only directories under a source path to a destination directory:

rsync --archive --verbose --filter=""+ */"" --filter=""- *"" /path/to/src/ /path/to/dest/
rsync --archive --verbose --filter=""+ */"" --filter=""- *"" /path/to/apache/logs/ user@domain:/path/to/apache/logs/

Using options --include and --exclude instead of --filter rules with an older version of rsync:

rsync --archive --verbose --include=""*/"" --exclude=""- *"" /path/to/src/ /path/to/dest/
rsync --archive --verbose --include=""*/"" --exclude=""*"" /path/to/apache/logs/ user@domain:/path/to/apache/logs/"