Le 13/03/2011 18:10, Jan-Benedict Glaw a écrit :
On Sun, 2011-03-13 16:10:12 +0000, Adnane RABIH<rabihadn...@gmail.com> wrote:
I made a script to backup a folder on a remote server it works
manually, I set a cron job to launch the script every 2 mins (for
test), I sse in the log this line
Mar 13 13:10:01 debian /USR/SBIN/CRON[6302]: (root) CMD (root
/usr/bin/backup.sh)
but when I sheck the remote server nothing is done, any sugestions pls
Seems you forgot to attach the script you wrote.
...and when you send it, please also tell us as which user you call it
and how your whole crontab looks like. (Some variables may be set there.)
MfG, JBG
yep:) thanks for your help
I found the script in a tutoriel and made some changes to it.
the 2 machines are Debian boxes 6.0
#crontab -e
# m h dom mon dow command
*/5 * * * * root /usr/bin/backup.sh
# cat /etc/crontab
SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
# m h dom mon dow user command
17 * * * * root cd / && run-parts --report /etc/cron.hourly
25 6 * * * root test -x /usr/sbin/anacron || ( cd / &&
run-parts --report /etc/cron.daily )
47 6 * * 7 root test -x /usr/sbin/anacron || ( cd / &&
run-parts --report /etc/cron.weekly )
52 6 1 * * root test -x /usr/sbin/anacron || ( cd / &&
run-parts --report /etc/cron.monthly )
#
cron.log
Mar 13 17:10:01 debian /USR/SBIN/CRON[21083]: (root) CMD (root
/usr/bin/backup.sh)
cat /usr/bin/backup.sh
#!/bin/bash
# Author: Brice Burgess - b...@iceburg.net
# rbackup.sh -- secure backup to a remote machine using rsync.
# Directories to backup. Separate with a space. Exclude trailing slash!
SOURCES="/home/adnane/these"
# IP or FQDN of Remote Machine
RMACHINE=mydomaine.com
# Remote username
RUSER=root
# Directory to backup to on the remote machine. This is where your backup(s)
will be stored
# Exclude trailing slash!
RTARGET="/root/backup"
# Your EXCLUDE_FILE tells rsync what NOT to backup. Leave it unchanged, missing
or
# empty if you want to backup all files in your SOURCES. If performing a
# FULL SYSTEM BACKUP, ie. Your SOURCES is set to "/", you will need to make
# use of EXCLUDE_FILE. The file should contain directories and filenames, one
per line.
# An example of a EXCLUDE_FILE would be:
# /proc/
# /tmp/
# /mnt/
# *.SOME_KIND_OF_FILE
EXCLUDE_FILE=
# Comment out the following line to disable verbose output
VERBOSE="-v"
#######################################
########DO_NOT_EDIT_BELOW_THIS_POINT#########
#######################################
if ! ssh $RUSER@$RMACHINE "test -x $RTARGET"; then
echo "Target directory on remote machine doesn't exist or bad permissions."
echo "Exiting..."
exit 2
fi
echo "Verifying Sources..."
for source in $SOURCES; do
echo "Checking $source..."
if [ ! -x $source ]; then
echo "Error with $source!"
echo "Directory either does not exist, or you do not have proper
permissions."
exit 2
fi
done
if [ -f $EXCLUDE_FILE ]; then
EXCLUDE="--exclude-from=$EXCLUDE_FILE"
fi
echo "Sources verified. Running rsync..."
for source in $SOURCES; do
# Create directories in $RTARGET to mimick source directory hiearchy
if ! ssh $RUSER@$RMACHINE "test -d $RTARGET/$source"; then
ssh $RUSER@$RMACHINE "mkdir -p $RTARGET/$source"
fi
rsync $VERBOSE $EXCLUDE -a --delete -e ssh $source/
$RUSER@$RMACHINE:$RTARGET/$source/
done
exit 0
--
Please use reply-all for most replies to avoid omitting the mailing list.
To unsubscribe or change options: https://lists.samba.org/mailman/listinfo/rsync
Before posting, read: http://www.catb.org/~esr/faqs/smart-questions.html