Re: Backup with rsync

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Timothy Murphy wrote:
I've been using rsync to backup my desktop
to another machine linked by ethernet.

Actually, to date I have only been backing up
my own files, and have had no problems.
But I was thinking of backing up the whole system,
and I discovered that I would have to allow
root login with ssh.
I know how to do this in the sshd config
but would prefer not to do it if possible.

Is there a simple way round this?



You can ask the rsync program on the backup host to behave like a backup host.

Create /etc/rsyncd.conf something like this:
----
motd file = /etc/motd
max connections = 25
syslog facility = local3

[backups]
comment = Backup area
path = /backups
read only = no
list = yes
uid = root
gid = bin

[tmp]
comment = temporary file area
path = /tmp
read only = no
list = yes
hosts allow = 192.168.2.0/24 127.0.0.0/8 10.0.0.0
----

Now you can use it as root from a client and the backups server will preserve everything, including permissions.

Some years ago I found this script on the net somewhere. I have modified it a bit, but the thing works great.

Basically it does a full the first time, and then incrementals each time after that. The main trunk of the backup tree for each client is always current, and changeges go into directories by date changed. Its great!

#!/bin/sh

#########################################################
# Script to do incremental rsync backups
# Adapted from script found on the rsync.samba.org
# Brian Hone 3/24/2002
# This script is freely distributed under the GPL
#########################################################

##################################
# Configure These Options
##################################

###################################
# mail address for status updates
#  - This is used to email you a status report
###################################
MAILADDR=phil.meyer@xxxxxxxxxxx

###################################
# HOSTNAME
#  - This is also used for reporting
###################################
HOSTNAME=`hostname`

###################################
# directory to backup
# - This is the path to the directory you want to archive
###################################
BACKUPDIR=/

###################################
# excludes file - contains one wildcard pattern per line of files to exclude
#  - This is a rsync exclude file.  See the rsync man page and/or the
#    example_exclude_file
###################################
EXCLUDES=/usr/local/etc/rsync_excludes

###################################
# root directory to for backup stuff
###################################
ARCHIVEROOT=eragon::backups/${HOSTNAME}

#########################################
# From here on out, you probably don't  #
#   want to change anything unless you  #
#   know what you're doing.             #
#########################################

# directory which holds our current datastore
CURRENT=main

# directory which we save incremental changes to
INCREMENTDIR=`date +%Y-%m-%d`

# options to pass to rsync
OPTIONS="--force --ignore-errors --delete --delete-excluded \
--exclude-from=$EXCLUDES --backup \
--numeric-ids \
--backup-dir=/${HOSTNAME}/$INCREMENTDIR -av"

export PATH=$PATH:/bin:/usr/bin:/usr/local/bin

# make sure our backup tree exists
install -d $ARCHIVEROOT/$CURRENT

# our actual rsyncing function
do_rsync()
{
  rsync $OPTIONS $BACKUPDIR $ARCHIVEROOT/$CURRENT
}

# our post rsync accounting function
do_accounting()
{
echo "Backup Accounting for Day $INCREMENTDIR on $HOSTNAME:">/tmp/rsync_script_tmpfile
  echo >> /tmp/rsync_script_tmpfile
echo "################################################">>/tmp/rsync_script_tmpfile
  du -s $ARCHIVEROOT/* >> /tmp/rsync_script_tmpfile
echo "Mail $MAILADDR -s $HOSTNAME Backup Report < /tmp/rsync_script_tmpfile"
  Mail $MAILADDR -s "$HOSTNAME Backup Report" < /tmp/rsync_script_tmpfile
  echo "rm /tmp/rsync_script_tmpfile"
  rm /tmp/rsync_script_tmpfile
}

# some error handling and/or run our backup and accounting
if [ -f $EXCLUDES ]; then
       if [ -d $BACKUPDIR ]; then
               # now the actual transfer
               do_rsync && do_accounting
       else
               echo "cant find $BACKUPDIR"; exit
       fi
       else
               echo "cant find $EXCLUDES"; exit
fi





[Index of Archives]     [Current Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]     [Fedora Docs]

  Powered by Linux