Rsync command: Difference between revisions
From WikiMLT
mNo edit summary |
m Стадий: 6 [Фаза:Утвърждаване, Статус:Утвърден]; Категория:Linux Server |
||
(9 intermediate revisions by the same user not shown) | |||
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 == | == Copy a 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"> | 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/ | rsync -r surce-dir target-dir/ | ||
Line 7: | Line 7: | ||
rsync -r surce-dir/ target-dir/ | rsync -r surce-dir/ target-dir/ | ||
</syntaxhighlight> | </syntaxhighlight> | ||
== Sync a directory with another == | == Sync a directory with another == | ||
<syntaxhighlight lang="shell" line="1"> | <syntaxhighlight lang="shell" line="1"> | ||
rsync -rv --delete --append ./ /media/<user>/sd-card | rsync -rv --delete --append ./music/ /media/<user>/sd-card | ||
</syntaxhighlight> | </syntaxhighlight> | ||
<syntaxhighlight lang=" | == Recursive copy of a directory over SSH == | ||
<syntaxhighlight lang="shell" line="1" class="mlw-shell-gray"> | |||
rsync --progress -vrazh <local-source> <ssh-host>:<remote-destination> | rsync --progress -vrazh <local-source> <ssh-host>:<remote-destination> | ||
</syntaxhighlight> | </syntaxhighlight> | ||
* <code>-v</code> : verbose | * <code>-v</code> : verbose, | ||
* <code>-r</code> : copies data recursively (but don’t preserve timestamps and permission while transferring data | * <code>-r</code> : copies data recursively (but don’t preserve timestamps and permission while transferring data, | ||
* <code>-a</code> : archive mode, archive mode allows copying files recursively and it also preserves symbolic links, file permissions, user | * <code>-a</code> : archive mode, archive mode allows copying files recursively and it also preserves symbolic links, file permissions, user and group owner-ships and timestamps, | ||
* <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. | ||
== Copy a file from a remote instance over SSH == | |||
<syntaxhighlight lang="shell" line="1"> | |||
rsync --progress -avz -e "ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null" \ | |||
<remote-host>:"/home/<remote-use>/backups/backup-${TODAY}.tgz" "$BACKUP_DIR" | |||
</syntaxhighlight> | |||
* The <code>ssh</code> options are appropriate for automated solutions like <code>cron</code> jobs. | |||
== References == | |||
* GitHub: <code>metalevel-tech/simple-backup-solutions/'''[https://github.com/metalevel-tech/simple-backup-solutions/blob/master/incremental_backup Implement incremental backup with Rsync]'''</code>. | |||
* Tecmint.com: [https://www.tecmint.com/rsync-local-remote-file-synchronization-commands/ 10 Practical Examples of Rsync Command in Linux] | |||
<noinclude> | <noinclude> | ||
<div id='devStage'> | <div id='devStage'> | ||
Line 32: | Line 34: | ||
| Прндл = Linux Server | | Прндл = Linux Server | ||
| Прндл1 = Linux Desktop | | Прндл1 = Linux Desktop | ||
| Стадий = | | Стадий = 6 | ||
| Фаза = | | Фаза = Утвърждаване | ||
| Статус = | | Статус = Утвърден | ||
| ИдтПт = Spas | | ИдтПт = Spas | ||
| РзбПт = {{REVISIONUSER}} | | РзбПт = Spas | ||
| АвтПт = Spas | |||
| УтвПт = {{REVISIONUSER}} | |||
| ИдтДт = 4.08.2022 | | ИдтДт = 4.08.2022 | ||
| РзбДт = {{Today}} | | РзбДт = 14.08.2022 | ||
| АвтДт = 14.08.2022 | |||
| УтвДт = {{Today}} | |||
| ИдтРв = [[Special:Permalink/29924|29924]] | | ИдтРв = [[Special:Permalink/29924|29924]] | ||
| РзбРв = {{REVISIONID}} | | РзбРв = [[Special:Permalink/30171|30171]] | ||
| АвтРв = [[Special:Permalink/30172|30172]] | |||
| РзАРв = [[Special:Permalink/29931|29931]] | |||
| УтвРв = {{REVISIONID}} | |||
| РзУРв = [[Special:Permalink/29933|29933]] | |||
}} | }} | ||
</div> | </div> | ||
</noinclude> | </noinclude> |
Latest revision as of 10:04, 14 August 2022
Copy a 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 ./music/ /media/<user>/sd-card
Recursive copy of a directory over SSH
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 and group owner-ships and timestamps,-z
: compress file data,-h
: human-readable, output numbers in a human-readable format.
Copy a file from a remote instance over SSH
rsync --progress -avz -e "ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null" \
<remote-host>:"/home/<remote-use>/backups/backup-${TODAY}.tgz" "$BACKUP_DIR"
- The
ssh
options are appropriate for automated solutions likecron
jobs.
References
- GitHub:
metalevel-tech/simple-backup-solutions/Implement incremental backup with Rsync
. - Tecmint.com: 10 Practical Examples of Rsync Command in Linux