Skip to content

Instantly share code, notes, and snippets.

@pniaps
Forked from aymencis/backup.sh
Created February 20, 2023 01:29
Show Gist options
  • Save pniaps/ac3575774de5f2b5e02cddec5e5ff823 to your computer and use it in GitHub Desktop.
Save pniaps/ac3575774de5f2b5e02cddec5e5ff823 to your computer and use it in GitHub Desktop.
OVH NFS BACKUP
#!/bin/sh
# BACKUP SCRIPT
CONTACT="[email protected]"
MAIL="/tmp/mail"
if [ -e "/var/lock/backup.lock" ]
then
echo " BACKUP ALREADY STARTED !!" > $MAIL
cat $MAIL | mail -s "BACKUP REPORT" $CONTACT
rm $MAIL
else
touch /var/lock/backup.lock
echo "================================" >> $MAIL
echo "BACKUP STARTED: `date +%c` " >> $MAIL
echo "================================" >> $MAIL
echo "" >> $MAIL
echo "" >> $MAIL
echo "================================" >> $MAIL
echo " MOUNT NFS: `date +%c` " >> $MAIL
echo "================================" >> $MAIL
mount -t nfs ftpback-rbx3-312.ovh.net:/export/ftpbackup/ns123456.ip-12-345-678.eu /mnt/backup
echo "" >> $MAIL
echo "" >> $MAIL
echo "================================" >> $MAIL
echo "COPY /var: `date +%c` " >> $MAIL
echo "================================" >> $MAIL
rsync -avz /var /mnt/backup/ > /root/backup/backup.log
echo "" >> $MAIL
echo "" >> $MAIL
echo "/var COPIED " >> $MAIL
echo "" >> $MAIL
echo "" >> $MAIL
echo "================================" >> $MAIL
echo "COPY /etc: `date +%c` " >> $MAIL
echo "================================" >> $MAIL
echo "" >> $MAIL
echo "" >> $MAIL
rsync -avz /etc /mnt/backup/ >> /root/backup/backup.log
echo "/etc COPIED " >> $MAIL
echo "" >> $MAIL
echo "" >> $MAIL
echo "================================" >> $MAIL
echo " UMOUNT NFS: `date +%c` " >> $MAIL
echo "================================" >> $MAIL
umount /mnt/backup
echo "" >> $MAIL
echo "" >> $MAIL
echo " NFS UMOUNTED " >> $MAIL
echo "" >> $MAIL
echo "" >> $MAIL
echo "" >> $MAIL
echo "" >> $MAIL
echo "================================" >> $MAIL
echo " BACKUP FINISHED: `date +%c` " >> $MAIL
echo "================================" >> $MAIL
cat $MAIL | mail -s "BACKUP REPORT" $CONTACT
rm $MAIL
rm /var/lock/backup.lock
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment