LinHES Forums http://forum.linhes.org/ |
|
Can someone email me a copy of the R4V5 backup script http://forum.linhes.org/viewtopic.php?f=6&t=4759 |
Page 1 of 1 |
Author: | marc.aronson [ Tue May 31, 2005 10:12 pm ] |
Post subject: | Can someone email me a copy of the R4V5 backup script |
It's a long story, but I made the mistake of playing with the mytbackup script (/usr/local/bin/mythbackup) without saving the original. If someone could email me a copy of the script as it existed on a clean install, I would be very grateful. I am preparing to do an upgrade to R5, and need a clean backup for the upgrade to work properly. Thanks! Marc |
Author: | tjc [ Tue May 31, 2005 10:31 pm ] |
Post subject: | |
Better still, here is a fixed version which corrects several issues. This is what I used to make my backups before upgrading to R5A15.1. BTW - R5A16 is now out on at least some of the mirrors... Code: #!/bin/bash
# /usr/local/bin/mythbackup ######################################################################## DATABASE="mythconverg" BK_DIR="/myth/backup" BK_SQL="$DATABASE.sql" BK_ETC="etc.tar" BK_HME="home.tar" BK_GOD="root.tgz" SOUNDS="/usr/share/sounds" ######################################################################## [ -d "$BK_DIR" ] || exit 1 # # Play a sound to let you know I'm starting. (play $SOUNDS/beg.wav >& /dev/null)& # Check and fix mythconverg db to ensure clean copy cd /var/lib/mysql/mythconverg /etc/init.d/mythtv-backend stop /etc/init.d/mysql stop myisamchk -f *.MYI /etc/init.d/mysql start /etc/init.d/mythtv-backend start # None of this works if we're not in the right place! cd / # back up the old back, if present: [ -f "$BK_DIR/$BK_SQL" ] && mv -f $BK_DIR/$BK_SQL $BK_DIR/$BK_SQL.bak # Dumps the $DATABASE database mysqldump -u root $DATABASE > $BK_DIR/$BK_SQL # Tars newer part of /etc [ -f "$BK_DIR/$BK_ETC.gz" ] && mv -f $BK_DIR/$BK_ETC.gz $BK_DIR/$BK_ETC.gz.bak find ./etc ! -type d -newer /etc/.epoch -print0 | xargs -0 tar -uf $BK_DIR/$BK_ETC [ -f "$BK_DIR/$BK_ETC" ] && gzip -9 $BK_DIR/$BK_ETC # Tars newer part of /home [ -f "$BK_DIR/$BK_HME.gz" ] && mv -f $BK_DIR/$BK_HME.gz $BK_DIR/$BK_HME.gz.bak find ./home ! -type d -newer /home/.epoch -print0 | xargs -0 tar -uf $BK_DIR/$BK_HME [ -f "$BK_DIR/$BK_HME" ] && gzip -9 $BK_DIR/$BK_HME # Tars all of /root [ -f "$BK_DIR/$BK_GOD" ] && mv -f $BK_DIR/$BK_GOD $BK_DIR/$BK_GOD.bak tar czf $BK_DIR/$BK_GOD ./root chmod 740 $BK_DIR/$BK_GOD # Tars /home/mythtv/.mythtv and a few others tar -cjvpf /myth/backup/mythtv.tar.bz2 /home/mythtv/ /etc/mythtv/modules # Play a sound to let you know I'm done. (play $SOUNDS/end.wav >& /dev/null)& # exit 0 ######################################################################## # End |
Author: | marc.aronson [ Tue May 31, 2005 10:48 pm ] |
Post subject: | |
Fantastic -- thank you! |
Author: | marc.aronson [ Tue May 31, 2005 11:56 pm ] |
Post subject: | |
TJC, I'm not sure what's wrong. I've copied the scrip to /usr/local/bin/mythbackup, but when I try to run it from an xterm window I get the following error: Quote: : No such file or directory
Marc |
Author: | Greg Frost [ Wed Jun 01, 2005 1:04 am ] |
Post subject: | |
I have noticed that bash doesn't like files with DOS/Windows type line endings so depending on how you got the script onto your box, this may be your problem. If this is your problem you can remove them like so: Code: cat mythbackup | tr -d '\015' > mythbackup.tmp
mv -fv mythbackup.tmp mythbackup (On older versions you could just type "dos2unix mythbackup" but this does not appear to be available on my R5A15.1 box). |
Author: | Xsecrets [ Wed Jun 01, 2005 7:36 am ] |
Post subject: | |
nah probably simpler than that. do "chmod a+x scriptname" then try to run it again. though the line endings will get you particularly if you use notepad to create a script. has to do with carrage return / line feed windows uses both unix only uses one. which is why if you open a unix script in notepad you won't have any line breaks just little squares. |
Author: | tjc [ Wed Jun 01, 2005 11:22 am ] |
Post subject: | |
Failure to "chmod +x" would be my first guess too... To cure line ending issues you can always do something like this this (where "f" is set to the file name): Code: { tr -d '\015' <$f | awk '{print $0}' >$f.new ; } && mv $f.new $f
Adding awk in there fixes potential problems with a missing LF at the EOF. I could do the whole thing in one awk command, but then I'd have to think harder. Using dos2unix works too, if you have it, but since I'm away from the KnoppMyth box I'm not sure if we do. ![]() ![]() |
Author: | Greg Frost [ Wed Jun 01, 2005 7:21 pm ] |
Post subject: | |
tjc wrote: That gets ugly REAL fast.
![]() Yeah I learnt that the hard way. And have been reminded of it the hardway a few times since too ![]() |
Author: | marc.aronson [ Wed Jun 01, 2005 10:27 pm ] |
Post subject: | |
Greg Frost was correct -- stripping out the 015 (NL?) characters solved the problem! In terms of permissions -- I had already made sure that was set properly, but thanks for the suggestions! Marc |
Author: | Greg Frost [ Thu Jun 02, 2005 5:02 am ] |
Post subject: | |
wooohooo ![]() |
Author: | marc.aronson [ Sun Jun 05, 2005 11:31 am ] |
Post subject: | |
TJC, I saw your other post about this backup script and it sounds like the script your posted here is also correct for backuping up a V5A16 system. Is this correct? THanks! Marc |
Author: | tjc [ Sun Jun 05, 2005 2:27 pm ] |
Post subject: | |
Yep. As far as I can tell the only major changes since the script was written are back in the R3-R4 era, and include compressing the tarballs (which broke the two level backup) and adding the DB table check which broke the backup of the "./etc" "./root" and "./home" directories. |
Page 1 of 1 | All times are UTC - 6 hours |
Powered by phpBB® Forum Software © phpBB Group http://www.phpbb.com/ |