#!/bin/bash

SERVER_NAME="server1"
TIME=`date +%Y-%m`

GPG_COMMAND="gpg -c -z 0 --batch --passphrase pass"

FS_FILE=/tmp/$SERVER_NAME-fs.$TIME.tar.gz.gpg
#MYSQL_FILE=/tmp/$SERVER_NAME-mysql.$TIME.sql.gz.gpg

# Archiving filesystem
tar -cz /etc /root /home | $GPG_COMMAND > $FS_FILE

# Archiving databases
#mysqldump -u root --password=qwerty --all-databases | gzip | $GPG_COMMAND > $MYSQL_FILE

# Uploading to the cloud
curl --user user:pass -T $FS_FILE https://webdav.yandex.ru/

# Cleanup
unlink $FS_FILE
#unlink $MYSQL_FILE
