have been accustomed to using rsync + SSH server file synchronization, but before the command parameters to find similar mkdir-p function, you can synchronize a specified file automatically on the target server to create a complete parent directory on demand. For example, some of the automatically generated directory files by month and year need to be synchronized when the file is generated:
Copy Code code as follows:
RSYNC-LPRZTW--rsh= "/usr/bin/ssh-l rsyncuser"/var/2007/12/13/1001.gif 10.0.0.1:/var/2007/12/13/1001.gif
If the/VAR/2007/12/13 directory is not previously created on the target server, the synchronization will error: Rsync:push_dir#3 "/VAR/2007/12/13" Failed:no such file or directory (2)
The previous solution was to create all the new directory structures that might be created in advance on the target server, or to immediately rsync the directory to the target server when creating a new directory on the source server.
By accident, Rsync has a-r parameter (-r,--relative use relative path names) to synchronize the entire directory structure under the relative directory to the target server specified directory. Using this parameter can automatically achieve the effect of mkdir-p, only need to change the synchronization command:
Copy Code code as follows:
Cd/var
RSYNC-LPRRZTW--rsh= "/usr/bin/ssh-l rsyncuser" 2007/12/13/1001.gif 10.0.0.1:/var/