Backups por Bash


#!/bin/bash
today=$(date +%Y%m%d)
three_days_before=$(expr $today - 6)
site_path="/home/said/public_html/saidelbakkali_com/"
wp_path="${site_path}htdocs/"
backup_dir_path="${site_path}backup/"
dropbox_path="/SB_Backups"

wp_db_path=${wp_path}db_backup_${today}_database.sql
wp_backup_path=${backup_dir_path}complet_backup_${today}_uploads.tar.gz
wp_config=${site_path}wp-config.php

# Optimize database
/usr/local/bin/wp db optimize --path=$wp_path

# Backup database
/usr/local/bin/wp db export $wp_db_path --add-drop-table --path=$wp_path

# Backup uploads directory
tar -zcf $wp_backup_path --absolute-names $wp_path --add-file=$wp_config

# Upload backup to Dropbox
/usr/local/bin/dropbox_uploader upload $wp_backup_path $dropbox_path
/usr/local/bin/dropbox_uploader delete "/SB_Backups/complet_backup_${three_days_before}_uploads.tar.gz"

# Remove old backup
rm -rf $wp_db_path
rm -rf $wp_backup_path

Autor: Said El Bakkali
dropbox_uploader es https://github.com/andreafabrizi/Dropbox-Uploader

隆Qu茅 bueno que vuelvas!