Code : Tout sélectionner
#!/bin/bash
# LOCAL/FTP/SCP/MAIL PARAMETERS
SERVER="mafreebox.freebox.fr" # IP of Network disk, used for ftp
USERNAME="freebox" # FTP username of Network disk used for ftp
PASSWORD="xxxxxx" # FTP password of Network disk used for ftp
DESTDIR="/opt/backup" # used for temorarily storage
DOMO_IP="192.168.1.240" # Domoticz IP
DOMO_PORT="8080" # Domoticz port
### END OF USER CONFIGURABLE PARAMETERS
TIMESTAMP=`/bin/date +%Y_%m_%d_%H_%M_%S`
BACKUPFILE="domoticz_$TIMESTAMP.db" # backups will be named "domoticz_YYYYMMDDHHMMSS.db.gz"
BACKUPFILEGZ="$BACKUPFILE".gz
### Create backup and ZIP it
/usr/bin/curl -s http://$DOMO_IP:$DOMO_PORT/backupdatabase.php > /tmp/$BACKUPFILE
gzip -9 /tmp/$BACKUPFILE
### Send to Network disk through FTP
curl -s --disable-epsv -v -T"/tmp/$BACKUPFILEGZ" -u"$USERNAME:$PASSWORD" "ftp://$SERVER/Disque dur/backup_db/"
### Remove temp backup file
/bin/rm /tmp/$BACKUPFILEGZ
### Done!