|
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. |
|
Thread Tools | Search this Thread | Display Modes |
#1
|
|||
|
|||
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. |
#2
|
||||
|
||||
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 |
#3
|
|||
|
|||
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. |
#4
|
|||
|
|||
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. |
#5
|
|||
|
|||
Thanks, I'll make the change! Other than that, do you see anything else that shouldn't work?
Shawn |
#6
|
|||
|
|||
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. |
#7
|
|||
|
|||
Tested and working well now - thanks guys.
Someone, humor me and try this.. Shawn |
#8
|
|||
|
|||
Can you scrap winzip and go with 7 zip? A free solution would be good.
B |
#9
|
||||
|
||||
Quote:
sleep 15 You can download it here http://www.microsoft.com/downloads/d...displaylang=en |
#10
|
||||
|
||||
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!!! |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
|
|
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 |