!/bin/bash rm -rf /root/bbdd/* echo "Empezando copia …" TIMESTAMP=$(date +"%F") echo $TIMESTAMP BACKUP_DIR="/root/bbdd/$TIMESTAMP" mkdir -p $BACKUP_DIR MYSQL_USER="root" MYSQL=/usr/bin/mysql MYSQL_PASSWORD="laquesea" MYSQLDUMP=/usr/bin/mysqldump MYSQL_COMMAND=$MYSQL" --user="$MYSQL_USER" --password="$MYSQL_PASSWORD databases=$(echo "SHOW DATABASES" | $MYSQL_COMMAND | egrep -v '(performance_schema|information_schema|mysql)') echo $databases for db in $databases; do echo "Copiando … "$db $MYSQLDUMP --force --opt --user=$MYSQL_USER --password=$MYSQL_PASSWORD --databases $db | gzip > "$BACKUP_DIR/$db.gz" done rsync -avz -e ssh "$BACKUP_DIR/" copias@ipquesea:/home/copias/servidor/bbdd echo "Empezando copia web..." webs=$(for x in /home/*/public_html;do [ ] || echo $x;done) echo $webs for web in $webs; do web1=${web:5:-11} echo "Copiando a ... home/copias/servidor/html$web1" rsync -avz -e ssh "$web/" copias@ipquesea:"/home/copiasservidor/html$web1" done