Rsync command: Difference between revisions
From WikiMLT
mNo edit summary |
mNo edit summary |
||
Line 1: | Line 1: | ||
<noinclude>{{ContentArticleHeader/Linux_Server|toc=off}}{{ContentArticleHeader/Linux_Desktop}}</noinclude> | <noinclude>{{ContentArticleHeader/Linux_Server|toc=off}}{{ContentArticleHeader/Linux_Desktop}}</noinclude> | ||
== Copy directory == | |||
Recursive copy whole directory - the directory <code>source-dir</code> will be copied into the existing <code>target-dir</code>:<syntaxhighlight lang="shell" line="1"> | |||
rsync -r surce-dir target-dir/ | |||
</syntaxhighlight>Recursive copy a directory content - the content of the <code>source-dir</code> will be copied as content of the existing <code>target-dir</code>:<syntaxhighlight lang="shell" line="1"> | |||
rsync -r surce-dir/ target-dir/ | |||
</syntaxhighlight> | |||
== Sync a directory with another == | |||
<syntaxhighlight lang="shell" line="1"> | |||
== | rsync -rv --delete --append ./ /media/<user>/sd-card | ||
... | </syntaxhighlight>... | ||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
# Синхронизиране на музика със SD карта... | # Синхронизиране на музика със SD карта... | ||
Line 23: | Line 27: | ||
* <code>-z</code> : compress file data | * <code>-z</code> : compress file data | ||
* <code>-h</code> : human-readable, output numbers in a human-readable format | * <code>-h</code> : human-readable, output numbers in a human-readable format | ||
<noinclude> | <noinclude> | ||
<div id='devStage'> | <div id='devStage'> |
Revision as of 11:25, 4 August 2022
Copy directory
Recursive copy whole directory – the directory source-dir
will be copied into the existing target-dir
:
rsync -r surce-dir target-dir/
Recursive copy a directory content – the content of the source-dir
will be copied as content of the existing target-dir
:
rsync -r surce-dir/ target-dir/
Sync a directory with another
rsync -rv --delete --append ./ /media/<user>/sd-card
…
# Синхронизиране на музика със SD карта...
rsync -rv --delete --append ./ /media/spas/01CB-0E14
# Копиране през SSH
rsync --progress -avz -e "ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null" pa4080-szs-vps:"/home/pa4080/SystemBackup/szs-vps-backup-${TODAY}.tgz" "$BACKUP_DIR"
rsync
via ssh
(source):
rsync --progress -vrazh <local-source> <ssh-host>:<remote-destination>
-v
: verbose-r
: copies data recursively (but don’t preserve timestamps and permission while transferring data-a
: archive mode, archive mode allows copying files recursively and it also preserves symbolic links, file permissions, user & group ownerships and timestamps-z
: compress file data-h
: human-readable, output numbers in a human-readable format