View unanswered posts    View active topics

All times are UTC - 6 hours





Post new topic Reply to topic  [ 12 posts ] 
Print view Previous topic   Next topic  
Author Message
Search for:
PostPosted: Tue May 31, 2005 10:12 pm 
Offline
Joined: Tue Jan 18, 2005 2:07 am
Posts: 1532
Location: California
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


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 31, 2005 10:31 pm 
Offline
Joined: Thu Mar 25, 2004 11:00 am
Posts: 9551
Location: Arlington, MA
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


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 31, 2005 10:48 pm 
Offline
Joined: Tue Jan 18, 2005 2:07 am
Posts: 1532
Location: California
Fantastic -- thank you!


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 31, 2005 11:56 pm 
Offline
Joined: Tue Jan 18, 2005 2:07 am
Posts: 1532
Location: California
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


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 01, 2005 1:04 am 
Offline
Joined: Mon May 10, 2004 8:08 pm
Posts: 1891
Location: Adelaide, Australia
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).


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 01, 2005 7:36 am 
Offline
Joined: Mon Oct 06, 2003 10:38 am
Posts: 4978
Location: Nashville, TN
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.

_________________
Have a question search the forum and have a look at the KnoppMythWiki.

Xsecrets


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 01, 2005 11:22 am 
Offline
Joined: Thu Mar 25, 2004 11:00 am
Posts: 9551
Location: Arlington, MA
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. ;-) The big thing to avoid is trying to read the same file on stdin as you're writing on stdout. That gets ugly REAL fast. ;-)


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 01, 2005 7:21 pm 
Offline
Joined: Mon May 10, 2004 8:08 pm
Posts: 1891
Location: Adelaide, Australia
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 :?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 01, 2005 10:27 pm 
Offline
Joined: Tue Jan 18, 2005 2:07 am
Posts: 1532
Location: California
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


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 02, 2005 5:02 am 
Offline
Joined: Mon May 10, 2004 8:08 pm
Posts: 1891
Location: Adelaide, Australia
wooohooo :D . I finally got one right! (015=octal='\r'=carriage return)


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jun 05, 2005 11:31 am 
Offline
Joined: Tue Jan 18, 2005 2:07 am
Posts: 1532
Location: California
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


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jun 05, 2005 2:27 pm 
Offline
Joined: Thu Mar 25, 2004 11:00 am
Posts: 9551
Location: Arlington, MA
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.


Top
 Profile  
 

Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 12 posts ] 


All times are UTC - 6 hours




Who is online

Users browsing this forum: No registered users and 22 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group

Theme Created By ceyhansuyu