Forum Moderators: bakedjake
#!/bin/bash
suffix=$(date +%y%m%d)
cd /home/your-user-name/
nice -19 tar -c your-domainname-folder/ ¦ gzip -c > backups/archives/yourdomainname.com-$suffix.tar.gz
How would I tell it to put a few different domain names in the zip?
For instance my root looks like this
/website1/
/website2/
/website3/
/somefiles/
/otherfiles/
And I only want to zip up website1, 2 and 3 but not the others, how do I write this into my cron?
tar -c --exclude badfile1 --exclude badfile2 * ¦ gzip -c > backups/archives/yourdomainname.com-$suffix.tar.gz
nice -19 tar -c --exclude badfile1 --exclude badfile2 * ¦ nice -19 gzip -c > backups/archives/yourdomainname.com-$suffix.tar.gz
gunzip -c backupfile.tar.gz ¦ tar tv
To restore a specific file:
gunzip -c backupfile.tar.gz ¦ tar xv website1/myfile.html
To restore all files (and replace any existing files without asking):
gunzip -c backupfile.tar.gz ¦ tar xv
And if you're low on disk space, and your system has bzip2 installed, you can replace gzip with bzip2, replace gunzip with bunzip2, and replace .gz with .bz2. It'll take longer to run, but the backups should be a little smaller.