I have a directory structure and files like this
data/ data/a.txt data/folder/ data/folder/b.txt data/folder/folder/ data/folder/folder/c.txt ...
a.txt
, b.txt
, and c.txt
are large files that are computer-generated and renewed frequently. They should NOT be backuped -- but I want to backup the directory structure :
data/ data/folder/ data/folder/folder/
How can I do this with rsync and --exclude-from, without specifying every folder, but something like rsync -a data/* --exclude-from=exclude.rsync "" --onlyfoldersandnotfiles""
?
Thanks for help !
Rsync allows you to transfer only directory structure if you do not need the files at another location. To do so, add -f"+ */" -f"- *" before the source directory.
Exclude Files and Directories from a List. When you need to exclude a large number of different files and directories, you can use the rsync --exclude-from flag. To do so, create a text file with the name of the files and directories you want to exclude. Then, pass the name of the file to the --exlude-from option.
In order to keep two directories truly in sync, it's necessary to delete files from the destination directory if they are removed from the source. By default, rsync does not delete anything from the destination directory. You can change this behavior with the --delete option.
Rsync is a tool that can improve the reliability of local directory syncing and the file transfer process over remote systems. You can use the rsync command to create complex backups and smooth control over what and how a directory will sync.
rsync -a --include='*/' --exclude='*' source/ destination/
Basically, first include all directories, then exclude all files.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With