[mythtv-users] Small backup script

Yianni Vidalis yiannividalis at hotmail.com
Wed Sep 30 08:46:49 UTC 2009


I created a small script that takes backup of the whole database and some individual tables. I use it just before each update, to be on the safe side...
 
Perhaps someone else could use it, too.
 
 
It saves everything in /myth/backup, so create the folder if it doesn't already exist or change it to something else..
It compresses the dumps to save space.
 
Please change the your-mythtv-user and your-mythtv-password entries with the correct data.

Feel free to change it, improve it or delete it ;-).
 
Yianni.
 
 
#!/bin/bash
currentdate=$(date +%Y-%m-%d)
#echo $currentdate
backuproot=/myth/backup
vers=$(mysql -u your-mythtv-user mythconverg --password="your-mythtv-password" -e "select data from settings where value='DBSchemaVer' limit 1;" --skip-column-names -s)
prot=$(mythfrontend --version | grep rotocol | awk '{ print $4 }')
mythvers=$(mythfrontend --version | grep "MythTV Version" | awk '{ print $4 }')
echo
echo
echo Database Schema Version is $vers
echo Mythtv Version is $mythvers
echo Protocol Version is $prot
suff=$currentdate-$mythvers-$vers-$prot
fullpath=$backuproot/$suff
echo FullPath is $fullpath
mkdir $fullpath 2>/dev/null
echo
echo
echo Backup folder will be $fullpath
echo
echo Backing up dtv_multiplex...
mysqldump -u your-mythtv-user --password="your-mythtv-password" --opt mythconverg dtv_multiplex> $fullpath/dtv_multiplex_export-$suff.sql
echo Done.
echo
echo Backing up the mythconverg database...
mysqldump -u your-mythtv-user --password="your-mythtv-password" mythconverg -c> $fullpath/mythtv_backup-$currentdate-$suff.sql
echo Done.
echo
echo Backing up the channels...
mysqldump -u your-mythtv-user --password="your-mythtv-password" --opt mythconverg channel> $fullpath/channel_export-$suff.sql
echo Done.
echo
echo Backing up the recordings...
mysqldump -u your-mythtv-user --password="your-mythtv-password" -t mythconverg record recorded oldrecorded recordedprogram recordedrating recordedmarkup recordedseek> $fullpath/recordings-$suff.sql

echo Done.
rm -f $fullpath/*.gz 2>/dev/null
gzip $fullpath/*
ls -lah $fullpath 		 	   		  
_________________________________________________________________
Το What's New σας ειδοποιεί άμεσα για κάθε ενημέρωση. Μάθετε πώς.
http://home.live.com/


More information about the mythtv-users mailing list