Linux: rsync Copy Directories Structures Tree Only

Linux: rsync Copy Directories Structures Tree Only

To copy the directory structures (without the files) of a source directory to a destination directory using rsync, you can use the --dirs option.

For example, to copy the directory structure of /source/path to /destination/path, you can use the following rsync command:

rsync -av --dirs /source/path/ /destination/path/
Sou‮.www:ecr‬lautturi.com

This will copy the directory structure of /source/path to /destination/path, creating the same subdirectories in the destination directory. The files in the source directory will not be copied.

You can also use the --dry-run option to perform a test run of the rsync command, which will show you what will be copied without actually making any changes.

For example:

rsync -av --dirs --dry-run /source/path/ /destination/path/

This will display a list of the directories that will be created in the destination directory, but no changes will be made.

Keep in mind that the rsync command will not delete any directories in the destination directory if they are not present in the source directory. To delete directories in the destination directory that are not present in the source directory, you can use the --delete option.

For example:

rsync -av --dirs --delete /source/path/ /destination/path/

This will copy the directory structure of /source/path to /destination/path, creating the same subdirectories in the destination directory and deleting any directories in the destination directory that are not present in the source directory. The files in the source directory will not be copied.

Created Time:2017-10-30 10:17:48  Author:lautturi