Project

General

Profile

Feature #10786 » cavalcade-logs-rotate.sh

Boone Gorges, 2018-12-13 11:30 AM

 
1
#!/bin/bash
2

    
3
install_dir=$1
4
date=`date +"%Y%m%d"`
5
backup_path="/home/GC/bgorges/cavalcade-backups/logs/$date.sql"
6

    
7
if [ '' = "$install_dir" ]; then
8
  echo 'You must provide a WordPress installation directory.'
9
  exit 1
10
fi
11

    
12
cd $install_dir
13
wp db export --tables=wp_cavalcade_logs $backup_path
14
gzip $backup_path
15
wp db query "DELETE FROM wp_cavalcade_logs WHERE timestamp < NOW() - INTERVAL 1 WEEK" 
(2-2/2)