Extra-back up help please

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
Post Reply
eil
Posts: 1875
Joined: 13 Jan 2011 19:44

Extra-back up help please

Post by eil »

i remember there are lots of commands alllowing to save toolbar, folder view, PFA and many other things normally stored in main .ini. can somebaody please direct to me so such script or help with writing this?
this morning i started XY and all my config is gone for some reason, and auto-back up was 0kb. i don't want to know the 'cause, but main bad-mood-maker is the fact all custom buttons are gone :cry: i could re-set all things in settings, but i don't remember which tweaks were made.
the only thing i'm left with are those in independent files. XY always was a portable decentraliced app, so how about more "sepparation" of settings from "user-habbits"? :kidding:
Win 7 SP1 x64 100% 1366x768|1900x1080

Stefan
Posts: 1360
Joined: 18 Nov 2008 21:47
Location: Europe

Re: Extra-back up help please

Post by Stefan »

Ideas

1.)
If you have all stored in your XY "Application Data Folder", (use menu "Go > Go To Application Data Folder" to see)
it is enough to execute menu "File > Settings > Backup Application Data Folder..."
(more at http://www.xyplorer.com/xyfc/viewtopic. ... 408#p61408 , if you have a day or two to read that,
scroll down to "Backup or transfer settings to an other pc")


2.)
Here's a backup script by Donald
http://www.xyplorer.com/xyfc/viewtopic. ... 983#p33983 (not actual tested if it still works)


3.)
write a batch or vbscript to rar the XY "Application Data Folder" and use windows scheduler to execute this daily.
(need help on this?)

There may be already such script available, but I can't find one right now.

eil
Posts: 1875
Joined: 13 Jan 2011 19:44

Re: Extra-back up help please

Post by eil »

thanks for ideas Stefan, but all these variants were checked more or less before. i had few "crashes" like that, but less harmful, so this time i'm not going to set anything till safe method done.
idea is not to copy as a whole(which again is centraliced) but in parts: with scripting, save in different files all that user could change from fresh install = create a so-named "migration pack".
Win 7 SP1 x64 100% 1366x768|1900x1080

Stefan
Posts: 1360
Joined: 18 Nov 2008 21:47
Location: Europe

Re: Extra-back up help please

Post by Stefan »

eil wrote: idea is not to copy as a whole
but in parts: with scripting, save in different files all that user could change from fresh install".
I am not sure if I get you, or I miss something?

All settings are in the main INI file, called deafult "XYplorer.ini", located in "Application Data Folder" ( http://www.xyplorer.com/xyfc/viewtopic. ... 408#p61408 )

There you can see your settings. e.g.
[CustomButtons]
[Aliases]
[FileAssoc] PFA
[Favorites]

Do you need now a script to split that INI into parts on each section like "[CustomButtons]" ???




All others are in that "Application Data Folder", which you can backup in whole to extract later what you need.

Here is a backup script to run manually or scheduled from windows scheduler:

[spoiler]

Code: Select all

'// Backup whole XYplorer Applications Data Folder , v001, 2013-10-22 by Stefan
' - store this as plain text file with VBS extension in the XYplorer folder 
' - adjust the User Settings to match your environment
' - launch the VBS by double click to backup for XYplorer settings (or create a windows scheduler task)

'// === User Settings:
XYPath = ".\"
RARexe = XYPath & "Tools\Packer\rar.exe"
Backup_MainFolder = "D:\Backups\XYplorer\"
TimeStamp = Year(Now) & "_" & right(Month(Now),2) & "_" & right(Day(Now),2) &  "_" & right(hour(now),2) & right(minute(now),2)



'// === The Code:
Set WSS = Wscript.CreateObject("WScript.Shell")
Set FSO = Wscript.CreateObject("Scripting.FileSystemObject")

'//  create backup folder with date timestamp for plain copy
'BackupFolder = Backup_MainFolder & TimeStamp
'If Not FSO.FolderExists(BackupFolder) Then FSO.CreateFolder(BackupFolder)

'//  get XY "Application Data Folder" location
If FSO.FileExists(XYPath & "XYplorer.exe") Then
	XYVer = FSO.GetFileVersion(XYPath & "XYplorer.exe")
	startupini = XYPath & "startup.ini"
	If FSO.FileExists(startupini) Then
		Set objFile = FSO.GetFile(startupini)
		If objFile.Size > 0 Then
			Set objFile = FSO.OpenTextFile(startupini, 1)
			'File_ReadAll = objFile.ReadAll
			Do Until objFile.AtEndOfStream
				StrData = objFile.ReadLine
					If InStr(ucase(StrData), "PATH") Then
						StrData = right(StrData, Len(StrData) - InStr(StrData, "=") )
						If InStr(StrData, "%") Then
							StrData = WSS.ExpandEnvironmentStrings(StrData)
						End If
						Exit Do
					End If
			Loop
			objFile.Close
		End If
		XYData = StrData
	Else
	XYData = XYPath & "\Data"
	End If
Else
	MsgBox "wrong path to XYplorer.exe and startup.ini. Script quits."
End If

'//  Debug:
'MsgBox "XYData:   " & XYData
'WSS.run "explorer.exe /e," & XYData

'//  Plain copy
'FSO.CopyFolder  XYData, BackupFolder

'//  RARing
'RAR <command>  [ -<switches> ]  <archive>  [ <@listfiles...> ] [ <files...> ]  [ <path_to_extract\> ]
'a       		Add files to archive.
'-ep1 			Exclude base dir from names.
'-ag[format] 	Generate archive name using the current date and time.
WSS.run RARexe & " a -ep1 " & chr(34) & Backup_MainFolder & "\XY_v" & XYVer _
       & "_Settings-Backup_" & TimeStamp & ".rar" & chr(34) & " " & chr(34) & XYData & chr(34)

'//  Show result
WSS.run "explorer.exe /e," & Backup_MainFolder

'EOF

[/spoiler]


.

eil
Posts: 1875
Joined: 13 Jan 2011 19:44

Re: Extra-back up help please

Post by eil »

Stefan wrote:All settings are in the main INI file, called deafult "XYplorer.ini", located in "Application Data Folder" ( http://www.xyplorer.com/xyfc/viewtopic. ... 408#p61408 )

There you can see your settings. e.g.
[CustomButtons]
[Aliases]
[FileAssoc] PFA
[Favorites]

Do you need now a script to split that INI into parts on each section like "[CustomButtons]" ???
you've got the idea. :mrgreen: you see, when i reinstall windows i also copy some files from App Data(of other programs), but i really don't copy it as a whole. same here -i'd wish i could save/backup sections apart.
why am i so stubborn about simple rar and copy? 'cause i already have experience when it was bad =archive got corrupted and all together was lost.
btw i use portable XY, so all is in Data folder.
Win 7 SP1 x64 100% 1366x768|1900x1080

Stefan
Posts: 1360
Joined: 18 Nov 2008 21:47
Location: Europe

Re: Extra-back up help please

Post by Stefan »

eil wrote:
Stefan wrote:All settings are in the main INI file, called deafult "XYplorer.ini", located in "Application Data Folder" ( http://www.xyplorer.com/xyfc/viewtopic. ... 408#p61408 )

There you can see your settings. e.g.
[CustomButtons]
[Aliases]
[FileAssoc] PFA
[Favorites]

Do you need now a script to split that INI into parts on each section like "[CustomButtons]" ???
you've got the idea. :mrgreen:
OK, I can't really understand what is the advantage over single section file instead of the whole INI,
but here you have a XYplorer script to save each XYplorer.ini section to an own section.txt file to %temp% folder:

c:\Users\User\AppData\Local\Temp\xyptestexport\[Aliases].txt
c:\Users\User\AppData\Local\Temp\xyptestexport\[ColorFilter].txt
c:\Users\User\AppData\Local\Temp\xyptestexport\[ColorFilterInstant].txt
c:\Users\User\AppData\Local\Temp\xyptestexport\[CustomButtons].txt
c:\Users\User\AppData\Local\Temp\xyptestexport\[CustomCopy1].txt
...
..
.

Code: Select all

  ////XYplorer script to read INI file and get a whole section content
  
  //User Settings
  $OutFolder = "%temp%\xyptestexport";
   
  //The Code
  $INI = readfile("<xydata>\xyplorer.ini"); 
  $do=0; 
  $out="";
  foreach( $line, $INI, "<crlf>"){
     $c = substr($line, 0, 1);
     if($c == "[" ){$section=$line; $do=1;}
     if($do==1){
       if($line != ""){
           $out = $out . $line . "<crlf>";
       }else{
           //text $out; msg "$section done, continue?",1; 
           writefile("$OutFolder\$section.txt", $out);
           $do=0; 
           $out=""; 
       }
     }
  }
  msg "Done, see $OutFolder";

Or do you need a VBS instead?

eil
Posts: 1875
Joined: 13 Jan 2011 19:44

Re: Extra-back up help please

Post by eil »

no, xys is good. :appl:
i'l be somewhat shameless and in next line ask for improvement. if by any means it's too much, just say "i don't have time" or smt, that will be ok. :wink:

i don't need all of them at once, so it would be great if before saving there were some way to choose which sections to take from .ini
yet, a second script with ability to choose file(obviously one of these)and replace main .ini section with its contents.(+exit XY with no save settings so .ini was really edited)
a simple example as how can it be useful: i extract aliases and buttons from my home XY, and import onlу them to fresh install on work one. =if you happen to move from one appartment to another, you take furniture, not all the linoleum and dust. :biggrin:
Win 7 SP1 x64 100% 1366x768|1900x1080

Stefan
Posts: 1360
Joined: 18 Nov 2008 21:47
Location: Europe

Re: Extra-back up help please

Post by Stefan »

For the first one you can get something like this:
XYplorer_InputSelect_p75.png

Code: Select all

  ////XYplorer script to read INI file and get a whole section content
 
  ////User Settings
  $INI = readfile("<xydata>\xyplorer.ini");
  $OutFolder = "%temp%\xyptestexport";


  ////The Code

  ////get all sections header:
  $SectionArray = "";
  foreach( $line, $INI, "<crlf>"){
     $FirstSign = substr($line, 0, 1);
     if($FirstSign == "[" ){
         $SectionArray = $SectionArray . $line . "|";
     }
  }

  ////ask user to choose one or more:
  //inputselect(header, listdata, [separator="|"], [style=1], [cancel], [width=600], [height=400], [windowcaption])
  $chosen = inputselect(header, $SectionArray, ,2);


  ///do something with the chosen ones:
  //text "OK to proceed on:<crlf>" . replace($chosen, "|", "<crlf>");

  ////write the wanted section to separate files:
  //todo... (something like in the script some posts above)

  $do=0;
  $out="";
  foreach( $line, $INI, "<crlf>"){
     $c = substr($line, 0, 1);
     if($c == "[" ){$section=$line;} 
     ////if current $section is in $chosen-array, then do it:
     if(strpos($chosen, $section) > -1){$do=1;}
     if($do==1){
       if($line != ""){
           $out = $out . $line . "<crlf>";
       }else{
           //text $out; msg "$section done, continue?",1;
           writefile("$OutFolder\$section.txt", $out);
           $do=0;
           $out="";
       }
     }
  }
  msg "Done, see $OutFolder";


The rest of the script at "todo" can be done if I (or someone) get some free time. Done.




For the second issue I need even more time to think about.... maybe later. (remind me)
To see the attached files, you need to log into the forum.
Last edited by Stefan on 23 Oct 2013 11:05, edited 2 times in total.
Reason: added the "todo" part

eil
Posts: 1875
Joined: 13 Jan 2011 19:44

Re: Extra-back up help please

Post by eil »

Stefan, thanks for all the help. :)
Win 7 SP1 x64 100% 1366x768|1900x1080

Stefan
Posts: 1360
Joined: 18 Nov 2008 21:47
Location: Europe

Re: Extra-back up help please

Post by Stefan »

I had to wait myself this morning..... so I already was able to go ahead and do this for you (added above)





.

eil
Posts: 1875
Joined: 13 Jan 2011 19:44

Re: Extra-back up help please

Post by eil »

marwellous!! :appl:
Win 7 SP1 x64 100% 1366x768|1900x1080

Post Reply