SageTV Community  

Go Back   SageTV Community > SageTV Development and Customizations > SageTV Customizations
Forum Rules FAQs Community Downloads Today's Posts Search

Notices

SageTV Customizations This forums is for discussing and sharing user-created modifications for the SageTV application created by using the SageTV Studio or through the use of external plugins. Use this forum to discuss customizations for SageTV version 6 and earlier, or for the SageTV3 UI.

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 08-08-2007, 08:19 PM
Shield Shield is offline
Sage Aficionado
 
Join Date: Jun 2007
Posts: 405
Automated Sage backups...please be gentle!

Ok, I'll admit it. I'm a sage "tinkerer". I fool around in Sage all the time, and sometimes make bad mistakes. My network has quite a few copies of Sage 6.X lying around, and I wanted a nice easy way to have Sage get backed up to a different workstation automatically. Also, I wanted the backup to not get overwritten by yet a 2nd backup, so having the date stamped into the backup was key. Lastly, since my terabyte-sized hard drive volumes are formatted for 64k cluster size I wanted to compress the backup into a single file and remove the "slack".

So, here's what I've come up with:

This script does the following:

1. Stops the SageTV service.
2. Stops the SageTV Client.
3. Copies the entire Sage folder and all subdirectories to a separate folder, drive or network resource with the current date stamped into the backup folder.
4. Zips the Sage backup folder into a single, maximum compression zip file (retaining the date stamp in the filename).
5. Deletes the Sage backup files created in step 3 (doesn't touch the source obviously).
6. Restarts Sage.

Requirements:

1. Winzip Pro 10.x or higher (www.winzip.com)

2. WinZip Command Line Support Add-On 2.0 (http://www.download.com/WinZip-Comma...-10459186.html) (Free Add-on)

3. Beyond Logic's Process Killer (Freeware) - (http://www.beyondlogic.org/consultin...rocessutil.htm)

4. SageTV, Windows XP (can be modified for Vista).

Assumptions for this to work with minor modifications:

This assumes the following:
1. You have installed SageTV in the default directory (c:\program files\SageTV)
2. You are running SageTV 6.x or higher.
3. You are using Windows XP.

Quick steps:

1. Create a folder in the root of your c:\drive called "xbackup"
(Note: you can create a folder anywhere you like actually).
2. Download the process.exe from the above link and put "process.exe" in the "xbackup" folder.
3. Get Winzip installed, and install the command line options to their default location.
4. Navigate to the the Winzip (Default is c:\program files\winzip) folder and copy the file "WZZIP.EXE" to the "xbackup folder".
5. Create a new text document in the "xbackup" folder, and name it anything you like. Open it in Notepad and copy the following into the file:

for /F "tokens=1-4 delims=/- " %%A in ('date/T') do set myDate=%%D_%%B_%%C
net stop "SageTV"
ping -n 15 localhost > nul
process -q SageTV.exe
ping -n 15 localhost > nul
Xcopy "C:\program files\SageTV" D:\BACKUP_FOLDER\%myDate%\SageTV /e /c /i /h /y
wzzip -ep -P -r D:\BACKUP_FOLDER\%myDate%_Sage.zip i:\mirror1\Sage_Backups\%myDate%\
rd D:\BACKUP_FOLDER\%mydate% /S /Q
net start "SageTV" 5
"c:\Program Files\SageTV\SageTV\SageTV.exe"



(The D:\BACKUP_FOLDER you can change with whatever suits you best)

6. Save the file with any name you choose to the "xbackup" folder. You will need to replace the extension of the file to ".bat" instead of .txt. If you cannot see the file extension, open Windows Explorer, and select: Tools > Folder Options > View and uncheck "Hide Extensions for Known File Types)
For example, I saved my file as "Sage.bat"

7. Go to control panel, and select "Scheduled Tasks". You need to create a new scheduled task that automatically runs the newly created "Sage.bat" file. I set mine to run every 3 days, and I set it to run at a time I know I'm not watching Sage. Remember, this will completely stop and restart the Sage services and client gui.

The result? You know have a zip file (maximum compression) that contains a complete backup of your Sage directory (sub folders and files saved too) that will NOT get overwritten unless you run this script more than once a day!

Let me know how this works out for you. The hardest part originally was getting the folder automatically created based on the date...

Shawn




Edit #1 - Changed the "-k" to "-q" to gracefully close the SageTvTranscoder and SageTV client. Thanks GKusnick!
Edit #2 - Changed the firing order of stopping the Sage services. Thanks NyPlayer!

Last edited by Shield; 08-08-2007 at 09:44 PM.
Reply With Quote
  #2  
Old 08-08-2007, 08:52 PM
GKusnick's Avatar
GKusnick GKusnick is offline
SageTVaholic
 
Join Date: Dec 2005
Posts: 5,083
While I appreciate the effort you've put into this, I'm personally not too comfortable with the idea of forcibly killing processes as part of my routine maintenance. Since you're running SageTV as a service, you're at least shutting that part down cleanly via net stop. But for someone who doesn't use the service, forcibly killing the SageTV process could have very bad consequences for the integrity of wiz.bin -- probably not something you want to risk as part of a backup procedure.

I'd strongly suggest looking for cleaner ways to shut down SageTV.exe and SageTVTranscoder.exe. For instance, the following command line uses the SendMessage utility that comes with Sage to send a WM_CLOSE message to the SageTV window:

Code:
SendMessage -c SageApp -n SageWin -m 16 0 0
__________________
-- Greg
Reply With Quote
  #3  
Old 08-08-2007, 09:04 PM
Shield Shield is offline
Sage Aficionado
 
Join Date: Jun 2007
Posts: 405
Excellent idea! How about simply adding the -q switch? Do you feel comfortable with this?

Close Processes . . .

On the other hand if you want to gracefully close programs by sending them a WM_CLOSE message first, you can used the -q option. This allows processes to clean up, save files, flush buffers etc. However it can cause deadlocks. e.g trying to close Microsoft Word when a unsaved, but edited document is open will generate a dialog box "Do you want to save changes to document 1?". This will prevent winword.exe from exiting until a user responds to the prompt.

C:\>process -q wordpad.exe

Command Line Process Viewer/Killer/Suspender for Windows NT/2000/XP V2.01
Copyright(C) 2002-2003 Craig.Peacock@beyondlogic.org
Sending PID 1836 'wordpad.exe' WM_CLOSE Message. Timeout is 60 seconds.
wordpad.exe (PID 1836) has been closed successfully.
Reply With Quote
  #4  
Old 08-08-2007, 09:10 PM
nyplayer nyplayer is offline
SageTVaholic
 
Join Date: Sep 2005
Posts: 4,997
Shield,

One thing If you are going to kill the SageTV process. Your first step should be to stop the Service. That way nothing will corrupt the the DB.
__________________
Channels DVR UBUNTU Server 2 Primes 3 Connects TVE SageTV Docker with input from Channels DVR XMLTV and M3U VIA Opendct.
Reply With Quote
  #5  
Old 08-08-2007, 09:19 PM
Shield Shield is offline
Sage Aficionado
 
Join Date: Jun 2007
Posts: 405
Thanks, I'll make the change! Other than that, do you see anything else that shouldn't work?

Shawn
Reply With Quote
  #6  
Old 08-08-2007, 09:42 PM
Shield Shield is offline
Sage Aficionado
 
Join Date: Jun 2007
Posts: 405
I can't figure out a good way to do a 15 second pause just to be on the safe side, so I've added:

ping -n 15 localhost > nul

twice to the script. Let me know if there's an easier way..

I also removed the graceful close of the transcoder.exe as well, as it shuts down when the service stops.

Shawn

Last edited by Shield; 08-08-2007 at 09:45 PM.
Reply With Quote
  #7  
Old 08-08-2007, 09:47 PM
Shield Shield is offline
Sage Aficionado
 
Join Date: Jun 2007
Posts: 405
Tested and working well now - thanks guys.

Someone, humor me and try this..

Shawn
Reply With Quote
  #8  
Old 08-09-2007, 02:25 AM
bcjenkins bcjenkins is offline
SageTVaholic
 
Join Date: Jan 2006
Posts: 3,764
Can you scrap winzip and go with 7 zip? A free solution would be good.

B
Reply With Quote
  #9  
Old 08-09-2007, 04:10 AM
doc's Avatar
doc doc is offline
Sage Fanatic
 
Join Date: Jun 2006
Location: Leicester, England
Posts: 918
Quote:
Originally Posted by Shield View Post
I can't figure out a good way to do a 15 second pause just to be on the safe side, so I've added:

ping -n 15 localhost > nul

twice to the script. Let me know if there's an easier way..

I also removed the graceful close of the transcoder.exe as well, as it shuts down when the service stops.

Shawn
You can use the sleep utility from a windows resource kit, then add the line

sleep 15


You can download it here http://www.microsoft.com/downloads/d...displaylang=en
Reply With Quote
  #10  
Old 08-12-2007, 09:16 AM
owilsky's Avatar
owilsky owilsky is offline
Sage Aficionado
 
Join Date: Dec 2004
Location: Germany
Posts: 447
I use toxwizbak to backup my wiz.bak regularly.
I won't use this because I want to make fully automatic backups and this script does NOT check if there is a recording at the moment. I don't want to shut down the service while a recording is active at the moment
__________________
Oliver Kötter
------------
Check this thread for importing German TV Data into SageTV

Using SageTV 7.1.9, Java 1.6.0_24 Win7 Home Premium on an
Asus M4N78-AM Mainboard, AMD Athlon II X2 215, 4 GB RAM, 500 GB HDD, 2xTechnoTrend S-2400 as Network Encoder (LM DVB Smart Recorder), ATI Radeon HD 3450 with analog TV-Out on good old CRT TV (100Hz)
My avatar shows the world's best composer!!!
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
After Lockup - Sage Not working wolfpackmars2 SageTV Software 3 08-05-2006 10:23 PM
Sage UI disappears during playback Keith SageTV Software 17 03-03-2006 03:31 AM
How To: In-place recompression of Sage Recordings nielm SageTV Customizations 39 02-18-2006 11:32 PM
my new favorite way to configure nvidia card for sage aoehlke Hardware Support 0 11-22-2005 11:15 AM


All times are GMT -6. The time now is 12:02 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2023, vBulletin Solutions Inc.
Copyright 2003-2005 SageTV, LLC. All rights reserved.