Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have a very limited experience with shell scripting and would like to put in place some sort of script that backs up my blog (Wordpress) on a weekly basis.

Here is what I have so far

#!/bin/bash

# Determine current date
setenv CURDATE date +%Y%m%d

# Backup DB & email it to me
mysqldump dbname -u user -ppassword | gzip | uuencode ${CURDATE}dbname.sql.gz | mail -s "backup for dbname ${CURDATE}" my@email.com

cd /home/myhome

# Zip blog
tar cf - blog.mysite.me | gzip - > ~/backups/${CURDATE}blog.mysite.me.tar.gz

And this is where I am a bit stuck... I was thinking about emailing myself the blog directory but what happens when this becomes bigger then 10MB or so? how would I script this to split this and email me the chunks?

Another suggestion I have which I feel is better is to FTP the backups to another VPS that I own. But for the sake of space I would like to only keep the last 10 backups. How would I implement the part of the script script that:

  1. Upload backup
  2. Get list of files
  3. Gets count of files in the current dir (e.g. /home/myhome/backups/blog )
  4. If count > 10 delete oldest

Any help/advice or pointers with solving this problem would be much appreciated :)

share

merged by sysadmin1138 Apr 19 '11 at 20:22

this question was merged with Simple bash backup solution because it is an exact duplicate of that question.

comments disabled on deleted / locked posts

Browse other questions tagged or ask your own question.