Backup script

The current shell server i’m using returns bogus output for commands like df. Mind the negative value for 1-k blocks.

timvw@localhost:~$ df

Filesystem 1k-blocks Used Available Use% Mounted on
/dev/hda1 -780429856382 1 0 74% /

It thought it would be a good idea to have a backup once in a while, but most of the times when i did it, i forgot to backup my database. So i wrote a little backup.script that remembers to do that for me.

#!/bin/bash
###############################################################################
# Generate a backup file of homedirectory and database
# Author: Tim Van Wassenhove <timvw@users.sourceforge.net>
# Update: 2005-09-16 01:56:00
###############################################################################
# dump database
mysqldump -u username -ppassword -h invalid.org dbname > ~/mysql.dmp

# generate gzipped archive of homedirectory
tar -czf /tmp/backup.tgz ~

# move backup to homedirectory and change name
mv /tmp/backup.tgz ~/madoka-`date +%F`.tgz

# remove database dump
rm ~/mysql.dmp
 

Download the source for backup.txt.

This entry was posted on Monday, June 28th, 2004 at 00:55 and is filed under Bash. You can follow any responses to this entry through the RSS 2.0 feed. Both comments and pings are currently closed.

Comments are closed.