Backing up Apache and HTDOC folder using RSYNC

Good afternoon all. I am having a little trouble with trying to backup my Apache (conf.d and httpd.conf) files to another machine via RSYNC.

Setup:-
** Both machines are running Suse 11.0 and Apache 2.2 **
Machine 1 - Main Webserver, 192.168.1.225
Machine 2 - Backup Webserver, 192.168.1.223

Machine 2 has /etc/samba/smb.conf entries:-


[apache]
	comment = Apache
	path = /etc/apache2
	guest ok = yes
	read only = no
	force user = root

[htdocs]
	comment = WWW Base Folder
	path = /srv/www/htdocs/
	guest ok = yes
	read only = no
	force user = badger_fruit

Machine 1 has (while logged in a local user badger_fruit) had two folders created in /home/badger_fruit/data/

apache
htdocs

In the /etc/fstab on Machine 1 I have added the entries:-


# APACHE BACKUP FOLDERS
//192.168.1.223/apache	/home/badger_fruit/data/apache	cifs	username=root,password=##########,auto,uid=root,gid=root,_netdev	0	0
//192.168.1.223/htdocs	/home/badger_fruit/data/htdocs	cifs	username=badger_fruit,password=##########,auto,uid=badger_fruit,gid=users,_netdev	0	0

There is a cron job set to run the script below every 1 hour:-


#!/bin/sh
LOG_FILE=/home/badger_fruit/data/backup-log

echo >> $LOG_FILE
echo "------------------------------" >> $LOG_FILE
date >> $LOG_FILE
echo "------------------------------" >> $LOG_FILE

echo "Apache Backup ==> 192.168.1.223" >> $LOG_FILE

rsync -avz /etc/apache2/httpd.conf  /home/badger_fruit/data/backup/apache/ >> $LOG_FILE 2>&1
rsync -avz /etc/apache2/conf.d/*  /home/badger_fruit/data/backup/apache/conf.d/ >> $LOG_FILE 2>&1

Problem:-
When I call the backup script, I see in the log file the following :-



------------------------------
Tue Aug 11 15:09:42 BST 2009
------------------------------
Apache Backup ==> 192.168.1.223
sending incremental file list
rsync: chown "/home/badger_fruit/data/backup/apache/httpd.conf" failed: Permission denied (13)

sent 38 bytes  received 15 bytes  106.00 bytes/sec
total size is 8334  speedup is 157.25
rsync error: some files could not be transferred (code 23) at main.c(1031) [sender=3.0.2]
sending incremental file list
rsync: chown "/home/badger_fruit/data/backup/apache/conf.d/apache2-manual.conf" failed: Permission denied (13)
rsync: chown "/home/badger_fruit/data/backup/apache/conf.d/badger.conf" failed: Permission denied (13)
rsync: chown "/home/badger_fruit/data/backup/apache/conf.d/mod_perl.conf" failed: Permission denied (13)
rsync: chown "/home/badger_fruit/data/backup/apache/conf.d/nagios.conf" failed: Permission denied (13)
rsync: chown "/home/badger_fruit/data/backup/apache/conf.d/php5.conf" failed: Permission denied (13)
rsync: chown "/home/badger_fruit/data/backup/apache/conf.d/phpmyadmin.conf" failed: Permission denied (13)
rsync: chown "/home/badger_fruit/data/backup/apache/conf.d/zm.conf" failed: Permission denied (13)

sent 183 bytes  received 33 bytes  432.00 bytes/sec
total size is 5593  speedup is 25.89
rsync error: some files could not be transferred (code 23) at main.c(1031) [sender=3.0.2]

Can someone please help me figure out why this is failing? I would have expected it to work (but obviously not and now I am stuck!)

Many thanks for reading though the above!

So, I just wanted to post a quick update:
Instead of using SAMBA and RSYNCing to the mounted folder, I read a little more on RSYNC and it allows you to send files direct to a PC

eg

rsync -avz /srv/www/htdocs/ foo:/srv/www/htdocs/

(foo: being the destination PC).

Given that a go and it’s sent the files with no problem - just got to provide a password in the command line (more reading required!) and that should be that!

Hope this comes to some use to someone else as well as me!

Great you got it sorted