I have 2 servers. One is mounted as /mnt/server1/ and the other as /mnt/server2/ On…
- User
I have 2 servers.
One is mounted as
/mnt/server1/and the other as/mnt/server2/On
/mnt/server1/there is aprojectfolder with millions of subfolders and files. On/mnt/server2/there is noprojectfolder yet.I want to make a full mirror of the directory structure for
projectwith all permissions, modification dates, owners preserved on/mnt/server2/. I don't need to copy the files that are in these folders. I am only interested in the directory structure. How can I achieve this in Linux? Assistant
- User
Is there a dry mode of rsync operation?
Assistant
Yes,
rsynchas a "dry run" mode using the--dry-runor-nflag. This mode allows you to see whatrsyncwould do without actually performing the file transfers or changes.Example:
Let's say you want to mirror the
/mnt/server1/projectdirectory to/mnt/server2/projectusingrsyncand see what files would be copied without actually transferring them:bashrsync -avz --dry-run /mnt/server1/project/ /mnt/server2/project/Breakdown:
-a: This flag enables archive mode, which preserves permissions, ownership, timestamps, and symbolic links.-v: This flag enables verbose output, showing the files that would be transferred.- : This flag enables compression, which can speed up the transfer process.
- User
What other tools can be used to create a complete copy of the directory structure relative to a folder? Can't the tar utility help with this?
Assistant
- User
What other tools can be used to create a complete copy of the directory structure relative to a folder? Can't the cpio utility help with this?
Assistant
- User
How should I write a command for tar to archive only directories but not files?
Assistant
You can achieve this using the
-Toption withtaralong with thefindcommand to list only directories. Here's how:bashfind /mnt/server1/project -type d -print0 | tar -cf /path/to/archive.tar -T -Explanation:
find /mnt/server1/project -type d -print0: This part of the command uses to locate all directories within .
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.