File synchronization compares and synchronizes files and directories between your local
computer and the remote server, making sure both locations contain the same files and directories.
sync [options] <local path> <remote path>
local
path and remote path you can use either an absolute path or a relative path.
Options:
--direction,
-d
: synchronization type
localtoremote, l
: one-way synchronization replicating local files noton the server, removing files on the server that don’t exist on the local
directory.
remotetolocal, r
: one-way synchronization replicating remote files
on the local directory, removing files on the local directory that don’t
exist on the server.
bidirectional, b
: two-way synchronization replicating local files
not on the server and replicating remote files on the local directory,
no files are deleted.
--exists,
-e
: allow to specify how to handle files that exist on both sides:
ignore, i
: just ignore the files.
newer, n
: upload or download if the source is newer than the target.
size, s
: upload or download if file sizes are different. Ignored in the
bidirectional type.
sizeornewer, w
: upload or download if source is newer or file sizes are dif-
ferent. Ignored in the bidirectional
type.
--recursive,
-r
: synchronize recursively files and subdirectories.
Examples
Copy new and updated local files to server:
sync --direction localtoremote --recursive --exists newer /Files/website/
public_html /public_html
Backup remote files to local:
sync --direction remotetolocal --recursive --exists newer /Documents/backup /
files/documents