Backup XYplorer

Discuss and share scripts and script files...
Post Reply
jacky
XYwiki Master
Posts: 3106
Joined: 23 Aug 2005 22:25
Location: France
Contact:

Backup XYplorer

Post by jacky »

Okay so since I'm here, and just as an example of things, here's a little script that will backup your XY copy. That includes the EXE, all INI & DAT files of course, as well as two subfolders, FindTemplates and Scripts.
If you want the help as well, or your Thumbs subfolder, etc you'll have to adjust things of course. (And no, the Scripts subfolder isn't there by default.)

Code: Select all

copyto "D:\Backup\XYplorer v<srcver> (on <dyyyy-mm-dd>)", "<xypath>\XYplorer.exe|<xydata>\*.ini|<xydata>\*.dat|<xydata>\FindTemplates|<xydata>\Scripts";
Proud XYplorer Fanatic

graham
Posts: 457
Joined: 24 Aug 2007 22:08
Location: Isle of Man

Post by graham »

This is a one of many very simple backup scripts I use which enable me to chose the backup drive before backup. On development work the choice of drive is very useful eg. frequent backup - C:, daily flash drive, weekly external drive

Incidentally, I now use a similar backup script for my email database backup (which has 14 years of data) because it is three times faster than the email program built in backup plus I include additional user files.


//Homepages Bu script list
// script
"script to BU Homepages data to drive"

status "Select drive to backup to";
input $drive, "Enter drive as C or D or...","C";
set $path, $drive:\BU Homepages\;
goto C:\Documents and Settings\home\My Documents\homepages\;
backupto $path, C:\Documents and Settings\home\My Documents\homepages\;
goto $path;
status "Backup of Homepages completed";

// end script

jacky
XYwiki Master
Posts: 3106
Joined: 23 Aug 2005 22:25
Location: France
Contact:

Post by jacky »

Well, since we're on backup things, here's another example. I use (a somewhat modified version of) this script when I need to "backup" the current folder into a RAR.
And I don't want more than one RAR per day, so I have it deleted first, meaning you always get either a "nothing to delete" or "are you sure" popup.

Code: Select all

"Some Backup"
	set $file, "Backup on <dyyyy-mm-dd>.rar";
	// delete old backup same date
	filter "$file";
	sel a;
	focus l;
	// delete
	#170;
	// create backup (exclude *.rar, recursive, don't include current folder name)
	open """winrar"" a -x*.rar -r -ep1 ""<curpath>\$file"" ""<curpath>\*""", s;
	// done
	filter;
Proud XYplorer Fanatic

RalphM
Posts: 2086
Joined: 27 Jan 2005 23:38
Location: Cairns, Australia

Re: Backup XYplorer

Post by RalphM »

I tried to use Jacky's script with a tiny change that apparently makes a big difference, here's the original:

Code: Select all

copyto "D:\Backup\XYplorer v<srcver> (on <dyyyy-mm-dd>)", "<xypath>\XYplorer.exe|<xydata>\*.ini|<xydata>\*.dat|<xydata>\FindTemplates|<xydata>\Scripts";
and this was my version:

Code: Select all

backupto "D:\Backup\XYplorer v<srcver> (on <dyyyy-mm-dd>)", "<xypath>\XYplorer.exe|<xydata>\*.ini|<xydata>\*.dat|<xydata>\FindTemplates|<xydata>\Scripts";
But with my version the only file copied to the parent backup folder was xyplorer.exe, therefore no *.dat or *.ini files. The folders from <xydata> were copied allright again.

Weren't backupto and copyto meant to share the same syntax?
Ralph :)
(OS: W11 25H2 Home x64 - XY: Current x64 beta - Office 2024 64-bit - Display: 1920x1080 @ 125%)

jacky
XYwiki Master
Posts: 3106
Joined: 23 Aug 2005 22:25
Location: France
Contact:

Post by jacky »

You know what, that might be a bug in the documentation (and by that I mean XYwiki)....

If I'm right, the support of wildchars comes from Windows and the fact that XY uses Windows API for move/copy operations, while the backup feature/command is XY-specific and, turns out, does not support wildchars but must be given path to actual files or folders only !
Which would explain why it doesn't work. So you'll have to use copyto, or simply put "<xydata>" in your source I guess.

Weird thing though, I tried this quickly and it didn't really work as expected:

Code: Select all

backupto "D:\Backup\XYplorer v<srcver> (on <dyyyy-mm-dd>)", "<xypath>\XYplorer.exe|<xydata>\";
I end up with a folder "XYplorer" inside the folder "XYplorer v7.00.0045 (on 2008-04-22)", which I guess maybe can make sense for "<xydata>\", but why no XYplorer.exe ?? :?
But I don't really have time to check this more now, and I'm a bit tired so I might be doing something wrong.
Proud XYplorer Fanatic

admin
Site Admin
Posts: 66075
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Post by admin »

jacky wrote:You know what, that might be a bug in the documentation (and by that I mean XYwiki)....

If I'm right, the support of wildchars comes from Windows and the fact that XY uses Windows API for move/copy operations, while the backup feature/command is XY-specific and, turns out, does not support wildchars but must be given path to actual files or folders only !
Which would explain why it doesn't work. So you'll have to use copyto, or simply put "<xydata>" in your source I guess.

Weird thing though, I tried this quickly and it didn't really work as expected:

Code: Select all

backupto "D:\Backup\XYplorer v<srcver> (on <dyyyy-mm-dd>)", "<xypath>\XYplorer.exe|<xydata>";
I end up with a folder "XYplorer" inside the folder "XYplorer v7.00.0045 (on 2008-04-22)", which I guess maybe can make sense for "<xydata>", but why no XYplorer.exe ?? :?
But I don't really have time to check this more now, and I'm a bit tired so I might be doing something wrong.
The explanation is correct: no wildcards allowed in the source(s) of backup.

The "weird thing" works fine here. It *might* depend on your setting for <xydata> (startup.ini), but I could not manage to produce your symptoms.

EDIT: I just rechecked the code and how it works, and updated the help file as such:
New Helpfile Entry wrote:Source
You can specify a source for the operation. The source must be the path to a folder or a file. You can use relative paths (relating to XYplorer's application folder), and variables (see examples below). When the source is a path, a trailing backslash is allowed but not necessary.

You can also use multiple sources by using pipe ( | ) as separator, for example:
backupto "D:\Backup\XY folders\<dyyyy-mm-dd>", "<xydata>\Scripts|<xydata>\FindTemplates"

In the case of copyto and moveto, the source(s) may contain wildcards, for example:
copyto "D:\Backup\XY files\<dyyyy-mm-dd>", "<xydata>\*.ini|<xydata>\*.dat"
Copies all *.ini and *dat file from the XYplorer data path to D:\Backup\XY files\2008-04-22\ (if that's the date today).
Note that backupto, however, does not support wildcards!

RalphM
Posts: 2086
Joined: 27 Jan 2005 23:38
Location: Cairns, Australia

Post by RalphM »

Today my UDC was gone, though I had used it yesterday - weird, until I remembered, that my XP shut itself down yesterday, which resulted in my XY settings not being saved and thats were my UDC went, so I added a "Save all settings" (#182) before the copy to prevent such losses in the future.

Code: Select all

#182; copyto "D:\Backup\XYplorer v<srcver> (on <dyyyy-mm-dd>)", "<xypath>\XYplorer.exe|<xydata>\*.ini|<xydata>\*.dat|<xydata>\FindTemplates|<xydata>\Scripts";
Ralph :)
(OS: W11 25H2 Home x64 - XY: Current x64 beta - Office 2024 64-bit - Display: 1920x1080 @ 125%)

jacky
XYwiki Master
Posts: 3106
Joined: 23 Aug 2005 22:25
Location: France
Contact:

Post by jacky »

Okay, I'm back on this because I'm not so tired now, and it still doesn't work for me :?

I started a fresh copy of XY 7.00.0046, that is I created a new folder "V:\tmp\XY" and put XYplorer.exe there, so there was nothing but whatever XY creates on startup.

Then I ran this script:

Code: Select all

backupto "Y:\XYplorer v<srcver> (on <dyyyy-mm-dd>)",
 "<xypath>\XYplorer.exe|<xydata>";
I expected to have a folder "Y:\XYplorer v7.00.0046 (on 2008-04-22)" containing XYplorer.exe and everything else there, right? But instead it was inside a subfolder "XY", as you can see from the report :

Code: Select all

Backup from 22/04/2008 22:43:28

Source: V:\tmp\
Target: Y:\XYplorer v7.00.0046 (on 2008-04-22)\

    2 copied
    0 overwritten
    1 not overwritten

    3 total

Copy V:\tmp\XY\XYplorer.exe
  -> Y:\XYplorer v7.00.0046 (on 2008-04-22)\XY\XYplorer.exe
NoOv V:\tmp\XY\XYplorer.exe
Copy V:\tmp\XY\XYplorer.ini
  -> Y:\XYplorer v7.00.0046 (on 2008-04-22)\XY\XYplorer.ini
I'm confused, what am I missing here ? :?:

Okay so trying a bit more, it seems that when XY was running from D:\F1\F2 it would always report D:\F1 (so the parent of <xypath>) as source of the backup operation.

So I tried running it from a root, since it has no parent, and from a XYplorer.exe running from W:\ and running the backupto script mentioned above, I get this:
XYplorer wrote:The following source item does not exist:
W:\
Press OK to go on anyway, or Cancel to terminate the file operation.
Sounds like a bug to me, no? Also, why does this only happens to me only ? (and no, I have no startup.ini)
Proud XYplorer Fanatic

admin
Site Admin
Posts: 66075
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Post by admin »

jacky wrote:Okay, I'm back on this because I'm not so tired now, and it still doesn't work for me :?

I started a fresh copy of XY 7.00.0046, that is I created a new folder "V:\tmp\XY" and put XYplorer.exe there, so there was nothing but whatever XY creates on startup.

Then I ran this script:

Code: Select all

backupto "Y:\XYplorer v<srcver> (on <dyyyy-mm-dd>)",
 "<xypath>\XYplorer.exe|<xydata>";
I expected to have a folder "Y:\XYplorer v7.00.0046 (on 2008-04-22)" containing XYplorer.exe and everything else there, right? But instead it was inside a subfolder "XY", as you can see from the report :

Code: Select all

Backup from 22/04/2008 22:43:28

Source: V:\tmp\
Target: Y:\XYplorer v7.00.0046 (on 2008-04-22)\

    2 copied
    0 overwritten
    1 not overwritten

    3 total

Copy V:\tmp\XY\XYplorer.exe
  -> Y:\XYplorer v7.00.0046 (on 2008-04-22)\XY\XYplorer.exe
NoOv V:\tmp\XY\XYplorer.exe
Copy V:\tmp\XY\XYplorer.ini
  -> Y:\XYplorer v7.00.0046 (on 2008-04-22)\XY\XYplorer.ini
I'm confused, what am I missing here ? :?:

Okay so trying a bit more, it seems that when XY was running from D:\F1\F2 it would always report D:\F1 (so the parent of <xypath>) as source of the backup operation.

So I tried running it from a root, since it has no parent, and from a XYplorer.exe running from W:\ and running the backupto script mentioned above, I get this:
XYplorer wrote:The following source item does not exist:
W:\
Press OK to go on anyway, or Cancel to terminate the file operation.
Sounds like a bug to me, no? Also, why does this only happens to me only ? (and no, I have no startup.ini)
Okay, correct. The problem was related to the fact that you can have independent sources in your script (in this case one item contains the other). This kind of situation was not foreseen when I originally designed the backup function. Should be fixed by now.

Also fixed the error with drives as top folder of the source.

admin
Site Admin
Posts: 66075
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Backup XYplorer Script

Post by admin »

Here's an updated Backup XYplorer Script based on a version posted by jacky. It will backup the whole currently running instance with all necessary data files, so you get a perfect clone in the backup location. Before the backup starts you get a small menu where you can decide whether to backup the current state in memory (needs to save to disk first), or whether to backup the state currently stored on disk.

Needs v7.90.0414 and take care to adjust the hardcoded Backup folder ($backupfolder) in the script.

Code: Select all

// needs v7.90.0414
"Save all settings first"
  savesettings;
  sub "_backup";
"Use current saved settings"
  sub "_backup";
"_backup"
  // backup startup.ini if it exists
  $startupini = exists("<xypath>\startup.ini")?"|<xypath>\startup.ini":"";
  // !! adjust this path !!
  $backupfolder = "D:\Backup";
  copyto "$backupfolder\XYplorer v<xyver> (on <date yyyy-mm-dd>)", 
  "<xypath>\XYplorer.exe$startupini|<xydata>";

admin
Site Admin
Posts: 66075
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: Backup XYplorer Script

Post by admin »

Version 2 - 2009-06-09 20:04
The previous script did a bad job in simply copying startup.ini, because if startup.ini contained an absolute path, the backup would still point to the original data instead of the backupped!
The new version below also handles appdata paths that are set via command line.


Here's an updated Backup XYplorer Script based on a version posted by jacky. It will backup the whole currently running instance with all necessary data files, so you get a perfect clone in the backup location. Before the backup starts you get a small menu where you can decide whether to backup the current state in memory (needs to save to disk first), or whether to backup the state currently stored on disk.

Needs v7.90.0414 and take care to adjust the hardcoded Backup folder ($backupfolder) in the script.

Code: Select all

// needs v7.90.0414
"Save all settings first"
  savesettings;
  sub "_backup";
"Use current saved settings"
  sub "_backup";
"_backup"
  // !! adjust this path as you need and like !!
  $backupfolder = "D:\Backup\XYplorer v<xyver> (on <date yyyy-mm-dd>)";
  // two ways to go, depending on <xydata>
  if ("<xypath>" != "<xydata>") {
    // appdata is set by startup.ini or command switch
    copyto "$backupfolder", 
        "<xypath>\XYplorer.exe";
    copyitem "<xydata>", "$backupfolder\appdata";
    // create new startup.ini pointing to appdata
    writefile("$backupfolder\startup.ini", "[Appdata]<crlf>Path=appdata");
  } else {
    // all in one folder: simply copy that folder
    copyitem "<xypath>", "$backupfolder";    
  }

admin
Site Admin
Posts: 66075
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: Backup XYplorer Script

Post by admin »

Version 3 - 2009-06-15 10:37
The previous script copied only XYplorer.exe to app path IF an app data path was defined.
The new version below also copies XYplorer.hlp, XYplorer.cnt, XYplorer.gid and any other items from app path named "XYplorer.*".


Here's an updated Backup XYplorer Script based on a version posted by jacky. It will backup the whole currently running instance with all necessary data files, so you get a perfect clone in the backup location. Before the backup starts you get a small menu where you can decide whether to backup the current state in memory (needs to save to disk first), or whether to backup the state currently stored on disk.

Needs v7.90.0414 and take care to adjust the hardcoded Backup folder ($backupfolder) in the script.

Code: Select all

// needs v7.90.0414
"Save all settings first"
  savesettings;
  sub "_backup";
"Use current saved settings"
  sub "_backup";
"_backup"
  // !! adjust this path as you need and like !!
  $backupfolder = "D:\Backup\XYplorer v<xyver> (on <date yyyy-mm-dd>)";
  // two ways to go, depending on <xydata>
  if ("<xypath>" != "<xydata>") {
    // appdata is set by startup.ini or command switch
    copyto "$backupfolder", 
        "<xypath>\XYplorer.*";
    copyitem "<xydata>", "$backupfolder\appdata";
    // create new startup.ini pointing to appdata
    writefile("$backupfolder\startup.ini", "[Appdata]<crlf>Path=appdata");
  } else {
    // all in one folder: simply copy that folder
    copyitem "<xypath>", "$backupfolder";    
  }

Post Reply