Rsync

From ArchWiki
Revision as of 16:23, 14 June 2008 by Ink-Jet (Talk | contribs) (Simple Rsync Backup Howto)

Jump to: navigation, search

Tango-document-new.pngThis article is a stub.Tango-document-new.png

Notes: please use the first argument of the template to provide more detailed indications. (Discuss in Talk:Rsync#)

Introduction

The rsync protocol can be used to make quick and easy backups, as it only transfers files that have changed, which means backups are much quicker, than if you just copied all your files over every time. This tutorial aims to show you how to make a scheduled backup, using rsync, typically to a removable media.

Prerequisites

Obviously, to use rsync, you need rsync:

# pacman -S rsync

Configuration

We need to make a script that tells rsync to backup your data.

Open a text editor, for example:

# nano /etc/cron.daily/rsync.backup

In this location, it will be run daily, without any further configuration.

You need to paste this script into the text editor:

#!/bin/bash
rsync -ar --delete /folder_to_backup/ /location_to_backup/ &> /dev/null

-a means files are archived, -r means files are copied recursively, and --delete means files deleted on the source are deleted on the backup

Here, "folder_to_backup" needs to be changed to what you want to backup (/home/ , for example) and "location_to_backup" is where you want to back it up to (/media/disk , for example).

We now need to make it executable:

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

And that's it. It'll now run daily, as long as your cron daemon is configured correctly (which is out of the scope of this document).