server/backup.sh

32 lines
597 B
Bash
Raw Normal View History

2014-01-21 02:42:01 +00:00
#!/bin/sh
# This script mades backup of important things
2014-01-21 02:42:01 +00:00
cd `dirname "$0"`
source config.sh
chown "$SYNCHRO_USER" "$TO_BCKP"
2014-01-21 02:42:01 +00:00
if [ "$UID" = "0" ]
then
SCRIPT=`pwd`/`basename "$0"`
su -c "sh $SCRIPT $@" "$SYNCHRO_USER"
2014-01-21 02:42:01 +00:00
exit $?
fi
if mount | grep "$TO_BCKP" > /dev/null
then
mysqldump -u backup --password="$BCKP_PASS" fic > "$TO_BCKP"/db/`date +%Y%m%d-%H%M`.sql
2014-01-21 02:42:01 +00:00
2014-01-21 02:56:17 +00:00
rsync -avL misc "$TO_BCKP"
2014-01-21 02:42:01 +00:00
rsync -avL .git "$TO_BCKP"
2014-01-21 02:56:17 +00:00
rsync -avL logs "$TO_BCKP"
rsync -avL /var/log "$TO_BCKP"
rsync -avL true_files "$TO_BCKP"
2014-01-21 02:42:01 +00:00
else
echo No volume mounted on $TO_BCKP
2014-01-21 02:42:01 +00:00
fi