Skip to content

Instantly share code, notes, and snippets.

@peerasan
Last active December 12, 2020 22:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save peerasan/187993313b4ce2d41d6a836ee1e81918 to your computer and use it in GitHub Desktop.
Save peerasan/187993313b4ce2d41d6a836ee1e81918 to your computer and use it in GitHub Desktop.
simple folder backup
#!/bin/bash
DATE=$(date +%Y-%m-%d)
BACKUP_DIR="/mnt/backup-web/"
# To create a new directory into backup directory location.
#mkdir -p $BACKUP_DIR/$DATE
# take each website backup in separate name, use below format.
tar -zcvpf $BACKUP_DIR/my-website-$DATE.tar.gz /my-website
# Delete files older than X days
find $BACKUP_DIR/* -type f -mtime +3 -exec rm {} \;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment