Differences

This shows you the differences between two versions of the page.

Link to this comparison view

tech:linux:file:backups [2018/02/04 06:27]
tech:linux:file:backups [2018/02/04 06:27] (current)
Line 1: Line 1:
 +====== File System Backup ======
 +NOTE: THIS HAS NOT BEEN FULLY TESTED!
 +
 +Create a cron.daily job to backup a directory
 +
 +Below is the script for backing up website directory.
 +
 +===== Prerequisites =====
 +<​code>​
 +mkdir -p /​data/​backups/​www
 +</​code>​
 +
 +===== Script Updates ===== 
 +  * Backup location and MySQL Backup location includes the mysql directory
 +  * Create the backup directory
 +
 +===== Features =====
 +  * Backups up www data
 +  * Deletes backup older than 7 days
 +
 +File location: ​ /​etc/​cron.daily/​www_backup
 +
 +<file bash www_backup>​
 +#!/bin/sh
 +#
 +# WWW backup script
 +#
 +NOW=$(date +"​%Y-%m-%d-%H-%M-%S"​)
 +#
 +BACKUPLOC="/​data/​backups"​
 +WWWBACKUPLOC="​$BACKUPLOC/​www"​
 +BACKUPFILE="​$WWWBACKUPLOC/​backup-www-${NOW}.tar.gz"​
 +LOGFILE="​$WWWBACKUPLOC/​backup-www-${NOW}.log"​
 +FILE_DIR_PATH="/​data/​www"​
 +#
 +# Backup Data
 +tar -zcvf ${BACKUPFILE} -C $FILE_DIR_PATH . > $LOGFILE
 +chmod 600 $BACKUPFILE
 +#
 +/​usr/​bin/​find $WWWBACKUPLOC/​backup-www*.tar.gz -mtime +7 -exec rm {} \;
 +/​usr/​bin/​find $WWWBACKUPLOC/​backup-www*.log -mtime +7 -exec rm {} \;
 +#
 +exit 0
 +</​file>​
 +
 +===== Post Install =====
 +<​code>​
 +chmod 700 /​etc/​cron.daily/​www_backup
 +</​code>​
  

QR Code
QR Code tech:linux:file:backups (generated for current page)