Aller au contenu principal

True Image - schedule to exclude weekends

Thread solved

I have several Daily>Every 3 Hours incremental backup jobs from PCs to a NAS drive.

My NAS is set up to switch on every weekday from 9am to 10pm.

How can I schedule my backups to exclude weekends? The Weekly option allows me to select Mon-Fri, but I only get the option to enter a single time in the "At"  box.

Any suggestions would be appreciated.

Thanks,

Max

0 Users found this helpful

Max, welcome to these public User Forums.

The Acronis Scheduler is not flexible enough to be able to configure your backups to not run on weekends so you would need to use another method of achieving the same results.

You could set up a Pre Command to test for your NAS being available and abort the task if the NAS is not found (due to being powered off) but the downside here is that the normal error handling settings would cause the task to be retried multiple times before it completely fails!

The best alternative would be to use the Windows Task Scheduler to run your backup via a Windows batch file (to launch it) only on the days / times you want it to run.  The task would show as being not scheduled in the main ATI GUI.

See KB 47143: Acronis True Image: How to run backups from Command Line - for details of what you would need to put in a batch file for the Windows Task Scheduler.

Thanks for this, Steve - it's my first post and I must say I'm impressed to receive a response on the weekend.

The only reason I want to set this up is to avoid the multiple error notifications I receive on the weekends. Your suggestion to do the Pre Command, I assume, would throw up these messages anyway.

The Windows Task Scheduler suggestion seems sensible, but is a bunch of steps that I was hoping to avoid.

I actually submitted this request to Support a couple of years ago, but didn't get a response - I would have thought it would be easy to include as a Schedule option, but have been disappointed to see it not show up in recent True Image updates.

Anyway, happy to live with it for now - I might consider leaving my NAS on during the weekends as an option.

Max

 

 

 

I use a Pre-command on a couple of my backups which are designed to run every other week. I find it works great and does not have the effect Steve refers to. But that said, I do get a window popping up (very quickly) for the command. I'm sure I could do it quietly but I haven't worried about that.

Steve's idea to use the Task Scheduler is also a good option, but I think the pre-command is better as it keeps it all together and can then be used for other tasks as well.

Max, here are some possibilities for a pre-command...

1. Create a batch file as follows, and use it in the pre-command. Be sure to not run the backup job if the command fails.
for /f %%i in (' "powershell (get-date).DayOfWeek"') do set dow=%%i
if %dow% == "Saturday" exit /b 1
if %dow% == "Sunday" exit /b 1
exit /b 0

2. Create a VB script and then call it with a batch file...
Script (e.g. WeekendTest.vbs):
if WeekdayName(Weekday(date)) = 'Saturday' then wscript.quit (1)
if WeekdayName(Weekday(date)) = 'Sunday' then wscript.quit (1)
wscript.quit

Batch File:
WeekendTest.vbs
exit /b %errorlevel%

I just copied some code I use so forgive the lack of proper efficiency that I usually use.

 

Edit: Note that Saturday and Sunday must be in the local language.

Thanks Bruno - I have no experience with batch files/ scripts, etc. so I hope I've done the right thing (I've also referred to Acronis' Knowledge Base);

The WeekendTest.vbs file referenced above contains the following text;

for /f %%i in (' "powershell (get-date).DayOfWeek"') do set dow=%%i
if %dow% == "Saturday" exit /b 1
if %dow% == "Sunday" exit /b 1
exit /b 0

Have I set this up correctly?

When I click Test command nothing seems to happen but I do get the green tick and "succeeded" message. Perhaps I'll only know if it works next weekend?

Max

Max, I personally don't use VBS scripts but use PowerShell instead where I launch this via a small Windows batch file for convenience.

For this scenario, I would use the following files:

WeekdayOnly.BAT        (used for the ATI Pre Command)

@echo off

set PS="c:\windows\system32\WindowsPowerShell\v1.0\powershell.exe"
set task="D:\Powershell\Acronis\Backup\WeekdayOnly.ps1"
%PS% -ExecutionPolicy RemoteSigned -windowstyle Hidden -file %task%

WeekdayOnly.PS1    (called from the .BAT script)

$today = (get-date).DayOfWeek
Write-Host $today
if (($today -eq "Saturday") -or ($today -eq "Sunday")) {
Write-Host "Exiting with code 1"
exit 1}
write-host "Exiting with code 0"
exit 0

Thanks Steve - testing this now and at least it doesn't throw up any errors.

As a complete rookie with batch files and scripts - I don't know where everything goes, so I've made the following assumptions;

WeekdayOnly.BAT in the D:/ root

WeekdayOnly.PS1 in D:\Powershell\Acronis\Backup

 

 

Sorry Max, I should have said to put the 2 files in a suitable folder then adjust the powershell script to point to that folder / use the option for the Pre Command to select the bat file from where you put it.

On my own system I have a dedicated D:\Powershell folder where I put the scripts I create / use - hence why it reflected using that path.  You could put both files in the same folder such as your D:\ root folder.  The script should be changed:

set task="D:\WeekdayOnly.ps1"  

If using the D:\ root folder.

My apologies, Steve - I had responded previously to the wrong name... have now edited my post.

Both you and Bruno have been very helpful,

Max

frestogaslorastaswastavewroviwroclolacorashibushurutraciwrubrishabenichikucrijorejenufrilomuwrigaslowrikejawrachosleratiswurelaseriprouobrunoviswosuthitribrepakotritopislivadrauibretisetewrapenuwrapi
Contributions: 250
Commentaires: 7092

Added the reference to this topic to the Best Practices section https://forum.acronis.com/forum/best-practices-data-protection/acronis-… 

Steve, Bruno, thank you for sharing your experience with scripts!