Backup once every 2nd week

General Discussion in English
Post Reply
Lars
Posts: 3
Joined: Sun Dec 05, 2021 1:01 pm

Backup once every 2nd week

Post by Lars »

Hello,

I'm looking for a way to elegantly have a weekly chained backup to two different switching target folders. The " $2WEEKSDAYS" variable comes close. But due to the fact that the chained backups might take longer, the weekdays the idividual backups start are not set. I was woundering if there is some variable one youd use fpr odd and even weeks of the year?


Regards, Lars

tobias
Posts: 1589
Joined: Tue Mar 31, 2020 7:37 pm

Re: Backup once every 2nd week

Post by tobias »

Hello,
sorry for the delay, it is possible with a PascalScript. I will post one ASAP.

Lars
Posts: 3
Joined: Sun Dec 05, 2021 1:01 pm

Re: Backup once every 2nd week

Post by Lars »

Hi,

I would still be interested in a possible sollution?

Regards, Lars

tobias
Posts: 1589
Joined: Tue Mar 31, 2020 7:37 pm

Re: Backup once every 2nd week

Post by tobias »

Hello,
again sorry for the delay. I can send you a script and/or Syncovery update today.

So the destination path would alternate every 7 days between for example
D:\Data\ODD
and
D:\Data\EVEN ?

Is that correct? Or how would you like the odd/even folders named?

Also, does your week start on a Monday or Sunday?

tobias
Posts: 1589
Joined: Tue Mar 31, 2020 7:37 pm

Re: Backup once every 2nd week

Post by tobias »

Hello,
OK here's a sample script that adds ODD and EVEN to the end of the right-hand path, alternating every 7 days. It's not necessarily the same odd/even of the official week of the year, but it alternates correctly across years.

In this function, a new week starts every Monday.

If the right-hand path uses forward slashes, such as for FTP or cloud paths, you need to replace the backslashes in the function with forward ones.

Code: Select all

function OnGetProfilePathBeforeListing(const isRightSide:Boolean;
        var Path,UserName,Password:UnicodeString;
        var AuthKey,AuthKeyPassword:AnsiString;
        var Port:Integer):Boolean;
var today:Integer;
begin
  if isRightSide then begin
     today:=Trunc(Now)-2;
     if (today div 7) mod 2=1 then
        Path:=ConcatPathWithDelim(Path,'ODD','\')
     else
        Path:=ConcatPathWithDelim(Path,'EVEN','\');
     end;
  Result:=true;
  end;

Lars
Posts: 3
Joined: Sun Dec 05, 2021 1:01 pm

Re: Backup once every 2nd week

Post by Lars »

Tank you! I will have a look and test it.

Post Reply