Rsync command: Difference between revisions

From WikiMLT
m (Стадий: 4 [Фаза:Авторизиране, Статус:Разработен]; Категория:Linux Server)
m (Стадий: 5 [Фаза:Утвърждаване, Статус:Авторизиран]; Категория:Linux Server)
Line 34: Line 34:
  | Прндл  = Linux Server
  | Прндл  = Linux Server
  | Прндл1 = Linux Desktop
  | Прндл1 = Linux Desktop
  | Стадий = 4
  | Стадий = 5
  | Фаза  = Авторизиране
  | Фаза  = Утвърждаване
  | Статус = Разработен
  | Статус = Авторизиран
  | ИдтПт  = Spas
  | ИдтПт  = Spas
  | РзбПт  = Spas
  | РзбПт  = Spas
  | АвтПт  = {{REVISIONUSER}}
  | АвтПт  = Spas
  | УтвПт  = Spas
  | УтвПт  = {{REVISIONUSER}}
  | ИдтДт  = 4.08.2022
  | ИдтДт  = 4.08.2022
  | РзбДт  = 14.08.2022
  | РзбДт  = 14.08.2022
  | АвтДт  = {{Today}}
  | АвтДт  = 14.08.2022
  | УтвДт  = 4.08.2022
  | УтвДт  = {{Today}}
  | ИдтРв  = [[Special:Permalink/29924|29924]]
  | ИдтРв  = [[Special:Permalink/29924|29924]]
  | РзбРв  = [[Special:Permalink/30171|30171]]
  | РзбРв  = [[Special:Permalink/30171|30171]]
  | АвтРв  = {{REVISIONID}}
  | АвтРв  = [[Special:Permalink/30172|30172]]
  | РзАРв  = [[Special:Permalink/29931|29931]]
  | РзАРв  = [[Special:Permalink/29931|29931]]
| УтвРв  = {{REVISIONID}}
  | РзУРв  = [[Special:Permalink/29933|29933]]
  | РзУРв  = [[Special:Permalink/29933|29933]]
}}
}}
</div>
</div>
</noinclude>
</noinclude>

Revision as of 11:04, 14 August 2022

Copy a di­rec­to­ry

Re­cur­sive copy whole di­rec­to­ry – the di­rec­to­ry source-dir will be copied in­to the ex­ist­ing tar­get-dir:

rsync -r surce-dir target-dir/

Re­cur­sive copy a di­rec­to­ry con­tent – the con­tent of the source-dir will be copied as con­tent of the ex­ist­ing tar­get-dir:

rsync -r surce-dir/ target-dir/

Sync a di­rec­to­ry with an­oth­er

rsync -rv --delete --append ./music/ /media/<user>/sd-card

Re­cur­sive copy of a di­rec­to­ry over SSH

rsync --progress -vrazh <local-source> <ssh-host>:<remote-destination>
  • -v : ver­bose,
  • -r : copies da­ta re­cur­sive­ly (but don’t pre­serve time­stamps and per­mis­sion while trans­fer­ring da­ta,
  • -a : archive mode, archive mode al­lows copy­ing files re­cur­sive­ly and it al­so pre­serves sym­bol­ic links, file per­mis­sions, user and group own­er-ships and time­stamps,
  • -z : com­press file da­ta,
  • -h : hu­man-read­able, out­put num­bers in a hu­man-read­able for­mat.

Copy a file from a re­mote in­stance 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 op­tions are ap­pro­pri­ate for au­to­mat­ed so­lu­tions like cron jobs.

Ref­er­ences