#!/bin/sh
#
# create-backup.sh - create CVS backup and send it to remote server over ssh
#
# Developed by Lubomir Host 'rajo' <rajo AT platon.sk>
# Copyright (c) 2003 Platon SDG
# Licensed under terms of GNU General Public License.
# All rights reserved.
#
# $Platon: scripts/shell/cvs-backup/create-backup.sh,v 1.1 2003/07/16 07:39:31 rajo Exp $
REPOSITORY="/home/cvs"
DATE="`date "+%y-%m-%d.tar.asc"`"
OUTPUT="/tmp/cvs$DATE"
EXTRA="/home/cvs/cvskey.asc"
ADDRESS="rajo@platon.sk"
# Security option!
# PLEASE DON'T REMOVE LINE BELOW !!!
umask 277 # create write protected file
# First compress logs...
echo "Compressing logs:"
for i in "$REPOSITORY"/log/*.1.gz; do
echo " $i "
if [ -s "${i%.bak.1.gz}" ]; then
# add log at end of old file
gunzip "$i" && \
cat "${i%.bak.1.gz}" >> "${i%.gz}" && \
gzip "${i%.gz}"
# truncate log
echo -en > "${i%.bak.1.gz}"
fi
done
echo ""
echo "Packing $REPOSITORY"
rm -f "$OUTPUT"
trap 'rm -f $OUTPUT' 1 2 3 15
( tar cf - "$REPOSITORY" \
| gpg -a -r Platon -e --trusted-key 342869B9AD4C459F --compress-algo 1; \
cat "$EXTRA"; \
) > "$OUTPUT" || ( \
echo "Error creating '$OUTPUT', removing..."; \
rm -f "$OUTPUT" )
if [ -f "$OUTPUT" ]; then
cat "$OUTPUT" | ssh -T -1 "$ADDRESS" \
&& echo "CVS backup succesfully send to '$ADDRESS'" \
&& rm -f $OUTPUT \
#mail -s "CVS backup" "$ADDRESS" < "$OUTPUT" \
#&& rm -f $OUTPUT \
#&& echo "Mail send..." \
#&& echo "Removing file $OUTPUT"
fi
Platon Group <platon@platon.sk> http://platon.sk/
|