rsync is a very powerful and multifunctional tool. It is at once a network protocol and on the other side a program under the terms of the GPL for syncing files ( as example for backups ) over a network.
Installation
You can install rsync with Pakfire or by using the shell with:
pakfire install -y rsync
More Information (links)
HERE you can find a very good instruction for rsync.
You can find an instruction for incremental snapshots HERE (English); and HERE (German translation)
Instruction to backup files (Use of the shell is necessary)
In this example is rsync going to be installed on a host. This could be a client PC or the IPfire itself. After finishing these instructions you will be able to download files to your client PC from the directory inside the configuration ( read only!!!)
create the rsync-server configuration (with nano or vi)
vi /etc/rsyncd.conf
Paste this content inside your file, optionally customize them:
filename = /etc/rsyncd.conf
uid = nobody
gid = nobody
use chroot = no
max connections = 4
pid file = /var/run/rsyncd.pid
read only = yes
[hd1]
#Customize the directory
path = /media/harddisk1
comment = Harddisk 1
The rsync server is read only so, the client isn't able to modify files.
Create the initscript
vi /etc/init.d/rsync
Paste the content again:
filename = /etc/init.d/rsync
#!/bin/sh
# Begin $rc_base/init.d/rsync
# Based on sysklogd script from LFS-3.1 and earlier.
. /etc/sysconfig/rc
. $rc_functions
case "$1" in
start)
boot_mesg "Starting rsync daemon..."
loadproc rsync --daemon
;;
stop)
boot_mesg "Stopping rsync daemon..."
killproc rsync
;;
*)
echo "Usage: $0 (start|stop)"
exit 1
;;
esac
# End $rc_base/init.d/rsync
Change the permissions
chmod 755 /etc/init.d/rsync
Start the server
/etc/init.d/rsync start
Stop the server
/etc/init.d/rsync stop
Enable autostart of rsync
ln -s ../init.d/rsync /etc/rc.d/rc3.d/S65rsync
ln -s ../init.d/rsync /etc/rc.d/rc0.d/K35rsync
ln -s ../init.d/rsync /etc/rc.d/rc6.d/K35rsync
Dissable autostart of rsync
rm /etc/rc.d/rc3.d/S65rsync
rm /etc/rc.d/rc0.d/K35rsync
rm /etc/rc.d/rc6.d/K35rsync
Now the setup of the rsync-server is complete and you are able to syncronize files on your client PC with those on the server.
rsync -a -c -P -stats ipfire::hd1/files/ /backup/files/
This command, run from the target computer, syncs the files in /backup/files/
(the chosen directory on your target computer) with those from inside the directory /media/harddisk1/files
on your ipfire (change ipfire to its IP). The data on the target is the same as the data on ipfire.
As I have already mentioned, rsync has been setup as read only, but now you have read the instructions above, and you should be able to change that, if you wish, and sync files on ipfire with those on the target, i.e. make ipfire the target, and its data the same as the data on the target in the example given above.
rsync -a -c -P -stats backup/files/ ipfire::hd1/files/
This command, run from the target from the first example, will sync the files in the /media/harddisk1/files
on your ipfire (change ipfire to its IP) with those in /backup/files/
(the chosen directory on the former target computer). It will only work if the file permissions on your ipfire allow it to, however, I had to change the owner and group of /media/harddisk1
- and files and directories below - on my ipfire to nobody, the user running rsyncd on ipfire, to get it to work on mine. Security may be compromised with symbolic links as well. Please read the rsync documentation before you open up your ipfire with read only = false
in /etc/rsyncd.conf
on ipfire.