Skip to content

Instantly share code, notes, and snippets.

@afeijo
Created June 27, 2012 13:20
Show Gist options
  • Save afeijo/3004029 to your computer and use it in GitHub Desktop.
Save afeijo/3004029 to your computer and use it in GitHub Desktop.
Backup all sites files
#!/bin/bash
# crontab example:
# 2 */12 * * * /bin/sh /home/user/scripts/sites.sh
# Local directory for dump files
LOCALDIR=$HOME/backups/sites
#
#####################################
### Edit Below If Necessary #########
#####################################
cd $LOCALDIR
DATE=`eval date +%Y%m%d-%H%M`
# compactar a pasta sites
tar zcf sites_${DATE}.tgz /var/nginx/www -X $HOME/scripts/exclude.list
# proteger os arquivos
chmod 0440 *gz
# Delete older files
find $LOCALDIR -mtime +15 -delete
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment