Difference between revisions of "Rsync"

From ArchWiki
Jump to: navigation, search
m
m
Line 15: Line 15:
 
  $ rsync -P src dest
 
  $ rsync -P src dest
  
The {{Codeline|-P}} option is the same as {{Codeline|--partial -- progress}}, which keeps partially transferred files and shows a progress bar during transfer.
+
The {{Codeline|-P}} option is the same as {{Codeline|--partial --progress}}, which keeps partially transferred files and shows a progress bar during transfer.
  
 
===As a backup utility===
 
===As a backup utility===
  
The rsync protocol can easily be used for backups, only transferring files that have changed since the last backup. This tutorial describes how to configure scheduled backups using rsync, typically to some removable media.
+
The rsync protocol can easily be used for backups, only transferring files that have changed since the last backup. This section describes a very simple scheduled backup script using rsync, typically to some removable media.
  
 
First, create a script containing the appropriate command options:
 
First, create a script containing the appropriate command options:

Revision as of 04:09, 9 November 2009

rsync is an open source utility that provides fast incremental file transfer.

Installation

# pacman -S rsync

Usage

As a cp alternative

rsync can readily be used as an advanced cp alternative, specifically useful for copying larger files:

$ rsync -P src dest

The Template:Codeline option is the same as Template:Codeline, which keeps partially transferred files and shows a progress bar during transfer.

As a backup utility

The rsync protocol can easily be used for backups, only transferring files that have changed since the last backup. This section describes a very simple scheduled backup script using rsync, typically to some removable media.

First, create a script containing the appropriate command options:

Note: For the sake of this example, the script is created in the Template:Filename directory, and will be run once daily if a cron daemon is installed and properly configured. Configuring/using cron is outside the scope of this article.

Template:File

Template:Codeline 
means files are archived
Template:Codeline 
means files are copied recursively
Template:Codeline 
means files deleted on the source are deleted on the backup

Here, Template:Filename should to be changed to what needs to be backed-up (Template:Filename, for example) and Template:Filename is where the backup should be saved (Template:Filename, for example).

If backing-up to a remote host using SSH, use this script instead:

Template:File

Template:Codeline 
tells rsync to use SSH
Template:Codeline 
is the user on the host Template:Codeline

Finally, the script must be executable:

# chmod +x /etc/cron.daily/rsync.backup

For more examples, search Google for 'rsync backup script' or search the Community Contributions and General Programming Forum forums.