Skip to content

Instantly share code, notes, and snippets.

@leandromoreira
Created February 6, 2014 02:03
Show Gist options
  • Save leandromoreira/8837160 to your computer and use it in GitHub Desktop.
Save leandromoreira/8837160 to your computer and use it in GitHub Desktop.
It makes backup and purges it.
#!/bin/bash
set -e
NOW=$(date +"%m-%d-%Y-%H-%M")
SOURCE_FOLDER_BKP=$1
DEST_FOLDER_BKP=$2
## Compacting and making backup
tar -zcf $DEST_FOLDER_BKP/bkp.$NOW.tar.gz $FOLDER_TO_BKP
## Removing older than 5 days
find $FOLDER_TO_BKP -type f -mtime +5 -delete
## Usage
# ./bkp_purge.sh /home/path/logs/ /home/path/old.logs/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment