How to keep the full path with rsync?
rsync to back up data, you can preserve the full directory structure of your source data by using the
--archive) option. The
-a option is a shorthand for several other
rsync options, including
-r (recursive) and
-l (preserve symlinks), among others. It ensures that the directory structure is maintained in the destination.
Here's the basic syntax for using
rsync to back up data while preserving the directory structure:
rsync -av source_directory/ destination_directory/
In this command:
source_directoryis the directory you want to back up.
destination_directoryis the location where you want to store the backup.
-a option ensures that the full directory structure, along with file attributes and permissions, is preserved. The trailing slash after
source_directory/ is important; it tells
rsync to copy the contents of the directory rather than the directory itself. This way, you'll have the contents of
source_directory mirrored in
destination_directory, maintaining the directory structure.
Here's a breakdown of some of the options used:
-archive): Preserves a variety of file attributes and permissions, including recursive copying and symbolic link preservation.
-verbose): Displays detailed information about the files being copied, which can be helpful for monitoring the backup process.
You can adjust the command to suit your specific needs, such as excluding certain files or directories using the
--exclude option or specifying remote hosts for backup. The key to preserving the directory structure is to use the
-a option, which ensures that the source directory's structure is maintained in the destination.
Can git be used as a backup tool?
Git is primarily a version control system rather than a traditional backup tool. While it can help you manage and track changes to your source code and other text-based files, it is not designed as...Questions
Create a backup on-call schedule
To set up a secondary calendar, head over to the Who’s on-call tab and click on Add on-call calendar Adding additional (secondary) calendar can be useful if you’d like to have various people on-cal...Uptime
Why isn’t RAID a backup
RAID (Redundant Array of Independent Disks) is a technology used to improve the performance, availability, and reliability of data storage in a computer system. While it provides certain benefits, ...Questions
Make your mark
Join the writer's program
Are you a developer and love writing and sharing your knowledge with the world? Join our guest writing program and get paid for writing amazing technical guides. We'll get them to the right readers that will appreciate them.Write for us
Build on top of Better Stack
Write a script, app or project on top of Better Stack and share it with the world. Make a public repository and share it with us at our firstname.lastname@example.org
or submit a pull request and help us build better products for everyone.
See the full list of amazing projects on github