Created
August 5, 2014 10:32
-
-
Save alexclifford/54bc6c565fca233faca4 to your computer and use it in GitHub Desktop.
Quickly backup a bunch of directories on centos server
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
BACKUP_PATH="/root/backups/" | |
BACKUP_DIR=$BACKUP_PATH$(date +%F)"/" | |
TARGETS="/root/.bash_history /root/.bashrc /root/.ssh /root/.subversion /etc/httpd/conf /etc/httpd/conf.d /var/www /etc/ssh/sshd_config" | |
# Loop through $TARGETS and rsync them all to $BACKUP_DIR but maintaining their directory paths | |
for DIR in `echo $TARGETS` | |
do | |
mkdir -p $BACKUP_DIR$(dirname ${DIR}) | |
rsync -av $DIR $BACKUP_DIR$(dirname ${DIR}) | |
done | |
tar -czf $BACKUP_PATH$(date +%F).tar.gz $BACKUP_DIR | |
rm -rf $BACKUP_DIR |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment