-
Notifications
You must be signed in to change notification settings - Fork 0
/
autobackup
29 lines (25 loc) · 956 Bytes
/
autobackup
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/bin/bash
NOW=`date -I`
/usr/bin/mysqldump -h $MYSQL_HOST --password="$MYSQL_ROOT_PASSWORD" $MYSQL_BASE | bzip2 -9 > /tmp/backup.sql.bz2
tar -cvjf /tmp/backup.tar.bz2 /tmp/backup.sql.bz2
(
cat << EOF
From: "SAUVEGARDE @Dolidock" <$BACKUP_FROM>
To: "Backup@Dolidock" <$BACKUP_TO>
MIME-Version: 1.0
Subject: Sauvegarde Dolidock du $NOW
Content-Type: multipart/mixed; boundary="-"
This is a MIME encoded message. Decode it with "munpack"
or any other MIME reading software. Mpack/munpack is available
via anonymous FTP in ftp.andrew.cmu.edu:pub/mpack/
---
Content-Type: text/plain
Voici la sauvegarde du $NOW
ISMO Dolidock+ team
---
Content-Type: application/octet-stream; name="backup-$NOW.tar.bz2"
Content-Transfer-Encoding: base64
Content-Disposition: inline; filename="backup-$NOW.tar.bz2"
EOF
) | (cat - && /usr/bin/openssl base64 < /tmp/backup.tar.bz2 && echo "" && echo "---")\
| /usr/sbin/sendmail -f $BACKUP_FROM -S $SMTP_HOST -t --