Skip to content

Instantly share code, notes, and snippets.

@sople1
Created July 13, 2021 02:43
Show Gist options
  • Select an option

  • Save sople1/27ef63458cdd19f2794ca4992deee27b to your computer and use it in GitHub Desktop.

Select an option

Save sople1/27ef63458cdd19f2794ca4992deee27b to your computer and use it in GitHub Desktop.
data backup script
#!/bin/sh
dat=`date +%Y%m%d%H%M%S`
#echo $dat
echo "backing up current status..."
tar cfpz /backup/db/$dat-mysql.tgz /var/lib/mysql/*
tar cfpz /backup/web/$dat-sites-user.tgz /home/user/sites/*
#tar cfpz /backup/git/$dat-git.tgz /home/git/repositories/*
echo "removing old backup files..."
find /backup/db/ -mtime +7 -exec rm -f {} \;
find /backup/web/ -mtime +7 -exec rm -f {} \;
find /backup/git/ -mtime +1 -exec rm -f {} \;
echo "backup process is complete.[$dat]"
@sople1
Copy link
Author

sople1 commented Jul 13, 2021

if [ ! -d "/backup/db" ]; then mkdir -p /backup/db; fi

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment