Skip to content

Instantly share code, notes, and snippets.

@fuzzmz
Created March 23, 2012 09:21
Show Gist options
  • Save fuzzmz/2168872 to your computer and use it in GitHub Desktop.
Save fuzzmz/2168872 to your computer and use it in GitHub Desktop.
pelican/md code highlight example

This is a really simple bash script which creates a .tar.gz archive of the folders I specify. I could further improve the script by making it do incremental backups instead of creating a new archive each day, but considering that this is a fast and dirty version of it, and that I don't have that much stuff to back up, it'll do for now.

:::bash
#!/bin/sh
date
echo "############### Backing up files on the system... ###############"

backupfilename=server_file_backup_`date '+%Y-%m-%d'`

echo "----- Now tar, then zip up all files to be saved -----"
tar cvf /home/backup/${backupfilename}.tar /home/logs/* /home/stats/pisg.cfg /home/gugu/.znc/configs/znc.conf /home/repos/*
gzip /home/backup/${backupfilename}.tar
rm /home/backup/${backupfilename}.tar
chmod 755 /home/backup/${backupfilename}.tar.gz

echo "############### Completed backing up system... ###############"
date

The echo lines aren't really necessary, but I like having them there in case I run the script by hand for debugging purposes.

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