I try to prepare the rsync command that will:1. backup all files in the directory but not nested files2. backup certain directories3. delete files in the target directory when they are deleted in sourcersync -vtr --delete --exclude='*/' --include='includes/*' --include='js/*' --include='css/*' /home/gameboy/abc/* /home/gameboy/PartialMirror/abc/But this only copies files and doesn't copy any folders and doesn't do deleting. Could you help me to improve the command?
rsync command to backup files in the main directory and certain directories with deleting
files;directory;rsync;backup;delete
Strictly speaking, the following can be interpreted to be contradictory goals.  backup all files in the directory but not nested files i.e.--exclude='*/' backup certain directories - i.e. include some nested filesPlease see below for an explanation on why your arguments did not work as you intended them. Further below, see a suitable alternative that might suit your purpose (it satisfies #1, #3 and a version of #2).Why your command did not work:The way rsync processes your commandline arguments, the following arguments are equivalent to saying --exclude='*/'--exclude='/' --include='desired_subfolder/'i.e., your command excluded all nested files, thus excluding files in desired subfolders as well. This problem affects your second observation, namely that files in the target that are deleted in the source are not being deleted. Actually, your command works perfectly well in deleting such files at the top level. However, files one level below are not deleted since they are already excluded. It helps to remember that --delete refers to --delete-during, not --delete-before.Solutions that satisfies #1, #3 and version of #2:The following solution might suit your needsrsync -avz --delete --include='includes/*' --include='js/*' --include='css/*' --exclude='*/*' /home/gameboy/abc/ /home/gameboy/PartialMirror/abc/It satisfies the following: 1. Backs up all files and directories at depth 1, but not nested files. 2. Back up desired folders 3. Deletes files in destination that are not in source.Another more cumbersome choice is as follows  rsync -vlptgoDd --delete src/ dest/This satisfies #1 and #3, but avoids all nested files (remember that folders are also files in *nix). I avoided giving the -r option, so it is not recursive. Delete works and folders at depth 1 are copied. In addition to preserving timestamps (-t), I included the other typical options for archive copying. A more standard way to get different rsync behaviors in different folders is to sprinkle filter rules in a per-directory fashion through the hierarchy; i.e. create .rsync-filter files specific to each folder that demands a unique behavior. For example   rsync -avF src/ dest/