Search the Community
Showing results for tags 'backup'.
-
We need to transfer from windows server 2012 to windows server 2016, we didn't find a way using to transfer the data automatically or to email us after tasks are finished. Is there a way to copy the data with NTFS/Shared permissions and timestamps without any loss?
- 10 replies
-
Version 1.5.5
820 downloads
This is a folder backup tool, after i got tired of using tools made by others, that had either lack of functionality, or were overly complex, i decided to make my own, and this is it. MirrorDir mirrors dirs as the name says, simply select source and destination hit scan, review in the list if that's what you want it to do and press start copy. As this is a mirror sync tool, this means files that exist in destination but dont exist in source are marked for deletion. Other tools have other modes like the incrementing copy which does not delete anything, but i made this for me, only if there is a request i may think about adding features just for fun. Whats more? There's a save/load of profile and the profile is what contains the list of source and destination folders, these are kept in prefs.ini in folder MDir in local appdata. There are context menu's that allow for the removal of items from the profile list, either just for the list (in case you dont want to sync a specific folder, just this time) or delete from the list and the .ini . Best regards. -
Have you ever shut down the computer while still performing a backup? If not, then ignore this post. Otherwise, this program may be helpful. It is registered in the startup folder after a query and then runs with every system start and ends only with system shutdown. Whenever a backup activity begins or ends, a message is generated. This prevents the computer from being accidentally turned off while a backup is still active. ; BackupDetector.exe Backup attention popup. ;============================================================================================================== ; Programm Name: BackupDetector.exe ; Description: Monitoring backup activities. ; Whenever a backup activity starts or ends, a message is generated. ; This eliminates the possibility of accidentally turning off the computer while a backup is still active. ; Syntax: BackupDetector.exe (no Parameters) ; Return Value(s): None. It's a never ending programm. ; Author: Exit ( http://www.autoitscript.com/forum/user/45639-exit ) ; SourceCode: http://www.autoitscript.com/forum/index.php?showtopic=199161 Version: 2019.06.21 ; COPYLEFT: © 2019 Freeware by "Exit" ; ALL WRONGS RESERVED ;============================================================================================================== #pragma compile(AutoItExecuteAllowed, True) #AutoIt3Wrapper_Res_SaveSource=y #NoTrayIcon If Not @Compiled Then Opt("TrayIconHide", 0) Opt("ExpandVarStrings", 1) #include <_SingleScript.au3> ; http://www.autoitscript.com/forum/index.php?showtopic=178681 _SingleScript() ; Close all running scripts with the same name $l = (StringRight(@OSLang, 2) = "07") ? 0 : 1 ; German=0 other=1 $sScriptShortcut = @AppDataDir & "\Microsoft\Windows\Start Menu\Programs\Startup\" & StringTrimRight(@ScriptName, 3) & "lnk" If @Compiled Then If Not FileExists($sScriptShortcut) Then $rc = MsgBox(4 + 32 + 256 + 262144, Default, $l ? _ "Should the program run at every system start?" : _ "Soll das Programm bei jedem Systemstart ausgeführt werden?") If $rc = 6 Then $rc = FileCreateShortcut(@ScriptFullPath, $sScriptShortcut) MsgBox(64 + 262144, Default, ($rc ? "" : ("--> " & ($l ? "NO" : "KEINE") & " <-- ")) & _ ($l ? "Shortcut created in the startup folder." : "Verknüpfung im Startordner erstellt.")) EndIf EndIf EndIf $bMessagebox = False $hPid = 0 While Sleep(5000) If ProcessExists("vssvc.exe") Then ; is Volume Shadow Copy running? If $bMessagebox = False Then If $hPid Then ProcessClose($hPid) $sText = $l ? "The backup is now running. @HOUR@:@MIN@:@SEC@@LF@" & _ "Please do not turn off the computer." & @LF & _ "When the backup is finished, a new message appears." : _ "Die Sicherung läuft jetzt. @HOUR@:@MIN@:@SEC@@LF@" & _ "Den Computer bitte nicht ausschalten." & @LF & _ "Wenn die Sicherung beendet ist, erscheint eine neue Meldung." $sCommand = '$rc = MsgBox(64+262144,@ScriptName & " on " & @Computername,"' & $sText & '") + Sleep(2147483647)' ; Retain PID due to sleep $sCommand = '"' & StringReplace($sCommand, '"', '""') & '"' $hPid = ShellExecute(@AutoItExe, ' /AutoIt3ExecuteLine ' & $sCommand) $bMessagebox = True EndIf Else If $bMessagebox = True Then If $hPid Then ProcessClose($hPid) $sText = $l ? "The backup is done. @HOUR@:@MIN@:@SEC@@LF@" & _ "The computer can (but does not have to) be turned off." & @LF & _ "Thank you for your patience, now you can press 'OK'." : _ "Die Sicherung ist fertig. @HOUR@:@MIN@:@SEC@@LF@" & _ "Der Computer kann (aber muss nicht) ausgeschaltet werden." & @LF & _ "Vielen Dank für ihre Geduld. Nun können Sie 'OK' drücken." $sCommand = '$rc = MsgBox(64+262144,@ScriptName & " on " & @Computername,"' & $sText & '") + Sleep(2147483647)' ; Retain PID due to sleep $sCommand = '"' & StringReplace($sCommand, '"', '""') & '"' $hPid = ShellExecute(@AutoItExe, ' /AutoIt3ExecuteLine ' & $sCommand) $bMessagebox = False EndIf EndIf WEnd ; End of BackupDetector script
-
Hello, the following script is running quite nicely for a friend of mine doing a year of work and travel to have a backup at home for all the pics and movies taken with her mobile phone, The facts: At home: a VMWARE virtual machine with dropbox installed for her DB account On-the-Road: One mobile phone, Camera Uploads are activated for her dropbox account, one Laptop. The idea is to have a copy of *ALL* pictures and movies taken with the mobile phone *OUTSIDE* the dropbox folder, so that the DB Max Size is never exceeded. The script is running at home and doing this: Copy all content from the "Camera Upload Folder" within the dropbox folder to some folder *OUTSIDE* the DB folder Move all content from the "Camera Upload Folder" do some other folder *INSIDE* the DB folder to indicate, that the backup copies at home were done successfully Dropbox is also installed on the Laptop she has with her. So on the Laptop she checks from time to time the destination folder inside the dropbox folder and moves the pics / movies on the laptop to some other folder outside the dropbox as well. By that final step the images are moved out of the dropbox on the mobile phone as well, so that there is always space left to sync more pics / movies. As moving pics / movies out of the dropbox folder on the laptop doesn't touch the copies in the mobile phone's "Gallery", she has all the pics / movies at all three locations: Mobile Phone Laptop VM at home The folder names propably are different for non-German localized Windows and Dropbox, just modify them to meet your localization. DBox-Sync.au3
-
Profiler - yet another backup script for Firefox and Thunderbird profiles It automatically detects the last recently used profile directories of Firefox and Thunderbird (installed versions, no portables). Clicking the Backup-Button creates a complete Backup of the found profiles with a timestamp. Restore deletes the according profile dir and extracts the content of the selected archive into the profile directory. Uses Winrar as compression tool, but feel free to change it to your needs Best regards Marc Profiler.au3
-
- firefox
- thunderbird
-
(and 3 more)
Tagged with:
-
"Nimps" is a regional slang word, which means easy or simple or basic and such. I made a quick little script the other day to backup the visual studio project folder I was actively working on. Thought I'd generalise it for use with the current active windows explorer folder. When this script is running, and you hit "Ctrl and Shift and b", if a folder is open in windows explorer, it will copy the contents of it to your desired location ($GENERAL_BACKUP_FOLDER) including subfolders and its files and folders (so beware on deep directories) If you have command line version of 7zip (7za.exe) you can choose to compress the folder rather than just copy it ($ZIP_FOLDER = True), or both I suppose. Think that's all. Reading the code should tell you anything else. Oh, success or failure is indicated by a high or low frequency Beep(). #include <AutoItConstants.au3> #include <String.au3> HotKeySet("^+b", _Backup) ; ctrl and shift and b HotKeySet("!+b", _Exit) ; alt and shift and b Global Const $GENERAL_BACKUP_FOLDER = @ScriptDir & "Backup\" Global Const $ZIP_FOLDER = False Global Const $PATH_TO_7ZA = "D:\7za.exe" While 3 Sleep(300) WEnd ; High frequency beep if successful ; Low frequency beep if failed Func _Backup() Local $FOLDER_TO_BACKUP = "" Local $BACKUP_FOLDER = "" Local $CURRENT_BACKUP_FOLDER Local $WIN_TITLE = WinGetTitle("[Active]") Local $WIN_TEXT = WinGetText("[Active]") ; If text of window has no address, it is not a windows explorer If StringInStr($WIN_TEXT, "Address: ") Then Local $ACTIVE_EXPLORER_ADDRESS = _StringBetween($WIN_TEXT, "Address: ", @LF) If Not IsArray($ACTIVE_EXPLORER_ADDRESS) Then Beep(400, 150) Return @ScriptLineNumber EndIf $FOLDER_TO_BACKUP = $ACTIVE_EXPLORER_ADDRESS[0] Else Return MsgBox(0, "Info", "The active window is not explorer") EndIf ; Check to see if root drive is backup source If StringRight($FOLDER_TO_BACKUP, 2) = ":\" Then $Answer = MsgBox(4, "Warning", "You are about to attempt to backup a whole disk" & @CRLF & "Are you sure?") If $Answer <> 6 Then Return EndIf ; Date and time to append to backup zip file or folder $APPEND = "_" & @YEAR & "_" & @MON & "_" & @MDAY & "_" & @HOUR & "_" & @MIN & "_" & @SEC Local $CURRENT_BACKUP_FOLDER = $GENERAL_BACKUP_FOLDER & $WIN_TITLE & $APPEND ; Zip to backup folder and return, 7za.exe required If $ZIP_FOLDER Then ; Buile command for 7za $command = $PATH_TO_7ZA & ' a ' & '"' & $GENERAL_BACKUP_FOLDER & $WIN_TITLE & $APPEND & '"' & '.zip ' & '"' & $FOLDER_TO_BACKUP & '"' $pid = Run($command, "", @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD) While ProcessExists($pid) Sleep(10) WEnd $out = StdoutRead($pid) ; Indicate if successfull If StringInStr($out, "Everything is Ok") Then Beep(700, 200) Return EndIf Beep(400, 200) Return EndIf ; Copy folder and beep when complete, no 7zip needed. Local $RTN = DirCopy($FOLDER_TO_BACKUP, $CURRENT_BACKUP_FOLDER, 1) ? Beep(700, 500) : Beep(400, 500) EndFunc ;==>_Backup Func _Exit() Exit EndFunc ;==>_Exit
-
Making a backup of the entire Registry
Wicked_Caty posted a topic in AutoIt General Help and Support
I wanted to have a few lines that copy the whole registry into a file. I know that there is RegRead, but I don't want to type every single key into my code... Any way of doing this easily? Filetype doesn't matter, as long as it isn't encrypted. A batch or exe would be okay, if it's in the same location on every PC. Doing this without admin permissions would be awesome too Thanks -
WARNING: I never tried this on a root directory, I should probably write a fix for that case. EX: There is no C:\..\ I don't know how many of these there are on this forum and I know Tidy is real nice for making backups. I have a few dislikes relying on the Tidy backup: 1 I'm not crazy about the backup folder it creates in project folder. 2. If no Tidy edits are performed script is not backed up on Tidy. I can't rely on that when I request a backup. 3. If I want to backup a select group of files without backing up the entire project folder, it is somewhat tedious to select each file and Tidy. Now this is just a very simple script that I felt I could use to simplify backing up my project. I'm not asking you to code it for me, but I welcome feedback. If you think you can make it better or know of something better please share. I know of Github it's overkill for me, I'm not comfortable, and I won't use it as much as I need to. So here it is: You place it in the source folder, open it in Scite. Change: Global $gBackup_dir_path = "..\Backup\" to wherever you want you backup folder Path to be. in the main() add some backup("file_name") calls remember to remove file extension. and it should make a new backup file for each backup("file_name") every time you run the script. Test it out make sure it's working and you're good to go. #cs ---------------------------------------------------------------------------- AutoIt Version: 3.3.14.2 Author: myName Script Function: To copy files to a backup folder. #ce ---------------------------------------------------------------------------- #include <File.au3> Global $gBackup_dir_path = "..\Backup\" ; Todo ; Add notes, options notes in file name main() func main() ; File list remember to remove extentions from file_name ; or add file extention as second parameter backup("Map_Editor") backup("DW_Server") EndFunc Func backup($spFile_name, $spFile_ext = ".au3") Local $error = 0 Local $iFile_num = 0 ; Make source file path Local $sFile_path_source = $spFile_name & $spFile_ext Local $sFile_path_dest = "" ; Sample the contents of the backup directory before creating a file there Local $aFile = _FileListToArray($gBackup_dir_path, $spFile_name&"*"&$spFile_ext, $FLTA_FILES) $error = @error If $error = 0 Then $iFile_num = $aFile[0] EndIf out("Found: " & $iFile_num & " files named: " & $spFile_name) Do ; Incroment file_num to find available file_name $iFile_num += 1 ; Path to Write File Copy $sFile_path_dest = $gBackup_dir_path & $spFile_name & "_" & $iFile_num & $spFile_ext ; Refuse to Overwrite File If FileExists($sFile_path_dest) = 0 Then ExitLoop EndIf ; Am I right? Sleep(30) Until 0 ; Create the file FileCopy($sFile_path_source, $sFile_path_dest, $FC_CREATEPATH) $error = @error If $error Then out("FileCopy() error: " & $error) out("sFile_path_source: " & $sFile_path_source & " sFile_path_dest: " & $sFile_path_dest) EndFunc ;==>backup Func out($output = "", $user = 0);debug tool ConsoleWrite(@CRLF & $output);to console new line, value of $output EndFunc ;==>out Backup_Script.au3 The script isn't authorized to overwrite files, and tries to create the next number of file_name available. The 'p' in my variable names stands for parameter.
-
This is a very simple application to backup a list of your local and network printers to a shared resource. when you restore the printers, the app will just install the printers that were networked. Feel free to improve upon and use. Let me know what you think I have many more applications and I may post more later. #include <File.au3> #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Global $Backpath = "\\Myawesomeserver\useraccounts" Global $fp = ($Backpath & @UserName) #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Printer Tools", 334, 75, 192, 124) $save = GUICtrlCreateButton("Save Printers", 8, 8, 155, 57) $load = GUICtrlCreateButton("Load Printers", 168, 8, 155, 57) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $save ExportPrinters() Case $load ImportPrinters() EndSwitch WEnd Func ImportPrinters() $File = $fp & "\NetworkPrinters.txt" FileOpen($File, 0) For $i = 1 to _FileCountLines($File) $line = FileReadLine($File, $i) RunWait(@ComSpec & " /c " & "rundll32 printui.dll,PrintUIEntry /in /n " & $line, "", @SW_HIDE) Next FileClose($File) Msgbox(0, "", "Network Printer Import Complete") endfunc ;==>ImportPrinters Func ExportPrinters() $wbemFlagReturnImmediately = 0x10 $wbemFlagForwardOnly = 0x20 $colItems = "" $Output = "" $nOutput = "" $objWMIService = ObjGet("winmgmts:\\" & @computername & "\root\CIMV2") $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_Printer", "WQL", _ $wbemFlagReturnImmediately + $wbemFlagForwardOnly) If IsObj($colItems) then For $objItem In $colItems If Stringinstr($objItem.DeviceID, "\\") then $nOutput = $nOutput & $objItem.DeviceID & @CRLF else $Output = $Output & $objItem.DeviceID & @CRLF endif Next FileWrite($fp & "\NetworkPrinters.txt", $nOutput) FileWrite($fp & "\LocalPrinters.txt", $Output) Else FileWrite($fp & "\Printers.txt", "No printers Found") Endif Msgbox(0, "", "Printer Export Complete") EndFunc ;==>ExportPrinters
-
I was too lazy to frequent backups my database on localhost via phpMyAdmin so I wrote a very simple script to backup databases via command com. Maybe it will be useful to someone... It backs up all or selected databases into one or separate sql files, e.g: single file output: 20130406.022354_drupal,test.sql separate files output: 20130406.022354_drupal.sql 20130406.022354_test.sql Recommended php utility to import .sql files into MySql: BigDump: Staggered MySQL Dump Importer #include <Array.au3> #include <Constants.au3> ; ------------------------------------------------------------------------ ; BACKUP MYSQL DATABASES ON LOCALHOST ; ------------------------------------------------------------------------ ; Definition and meaning: ; $export_defs ..... combine two constants: $cEXPORT_DB + ($cEXPORT_TO_... or $cEXPORT_AS_...) ; e.g. [ $cEXPORT_DB_ALL_DATABASES + $cEXPORT_TO_SINGLE_FILE ] => export all dbs to one file ; $custom_dbs ...... user-created databases. Use comma as separator, e.g. "drupal, joomla" ; $export_path ..... an export destination folder ; $dbUsr ........... user login credentials, usually 'root' ; $dbPwd ........... passwords for MySQL accounts ; $dbSrv ........... MySQL server, 127.0.0.1 for localhost ; $sMySqlPath ...... full path to MySQL bin directory ; $sSytemDbs ....... list of databases created during installation MySql app ; use this constants in variable $export_defs: Const $cEXPORT_DB_SYSTEMS_ONLY = 1 ; export default databases (e.g. XAMPP default databases) Const $cEXPORT_DB_NON_SYSTEMS = 2 ; export user-created databases (e.g. all non XAMPP default dbs) Const $cEXPORT_DB_ALL_DATABASES = 4 ; export all databases Const $cEXPORT_DB_CUSTOM_DATABASES = 8 ; export selected databases (e.g. 'Drupal' database only) Const $cEXPORT_TO_SINGLE_FILE = 128 ; export databases as one .sql file Const $cEXPORT_AS_SEPARATE_FILES = 256 ; export each stored database as separate .sql file ;=== user definition ===================================================>> Local $export_defs = $cEXPORT_DB_CUSTOM_DATABASES + $cEXPORT_AS_SEPARATE_FILES ;Local $export_defs = $cEXPORT_DB_NON_SYSTEMS + $cEXPORT_TO_SINGLE_FILE Local $custom_dbs = "drupal" ; as separator use comma, e.g. "drupal, joomla" Local $export_path = "E:\Backup\FullBackup\Aplikace\MySQL" Local $dbUsr = "root" Local $dbPwd = "123456" Local $dbSrv = "127.0.0.1" Local $sMySqlPath = "C:\xampp\mysql\bin\" Local $sSytemDbs = "cdcol, information_schema, mysql, performance_schema , phpmyadmin, test, webauth" ;=== user definition ==== (Do not change anything below this line) ====<< $export_path = StringRegExpReplace($export_path, "[\\/]+\z", "") & "\" $sMySqlPath = StringRegExpReplace($sMySqlPath, "[\\/]+\z", "") & "\" Local $sMySqlExe = FileGetShortName($sMySqlPath & "mysql.exe") Local $sMySqlDmpExe = FileGetShortName($sMySqlPath & "mysqldump.exe") Local $sFormat = "%s -u %s -p%s -h%s %s -e ""show databases"" -s -N" Local $sExtCmd = StringFormat($sFormat, $sMySqlExe, $dbUsr, $dbPwd, $dbSrv) Local $aSytemDbs = StringSplit(StringStripWS($sSytemDbs, 8), ",", 2) Const $2L = @LF & @LF If FileExists($sMySqlExe) <> 1 Then MsgBox(8240, "MySql.exe not found", "The mysql.exe not found!" & $2L & _ "The path '$export_path' is probably not being set properly.") Exit EndIf ; run in cmd Local $CMD = Run(@ComSpec & " /c " & $sExtCmd, "", @SW_HIDE, $STDERR_CHILD+$STDOUT_CHILD) ProcessWaitClose($CMD) Local $sMsg = StdoutRead($CMD) Local $sErr = StderrRead($CMD) ; if an error in mysql.exe (eg. server is not running) If StringInStr($sErr, "ERROR") <> 0 Then MsgBox(8208, "Error", $sErr) Exit EndIf If StringLen($sMsg) = 0 Then MsgBox(8208, "Error", "Failed to get databases names") Exit EndIf ; read all installed databases to $aAllDbs array Local $aAllDbs = StringSplit($sMsg, Chr(13), 2) For $i = UBound($aAllDbs) - 1 To 0 Step -1 $aAllDbs[$i] = StringStripWS($aAllDbs[$i],3) If StringLen($aAllDbs[$i]) = 0 Then _ArrayDelete($aAllDbs, $i) EndIf Next ; move requested names of databases to $aDbs array Select Case BitAND($export_defs, $cEXPORT_DB_SYSTEMS_ONLY) <> 0 $aDbs = $aSytemDbs Local $sResult = fncItemsInArray($aDbs, $aAllDbs) If @error Then MsgBox(8240, "Error", "Defined system database name '" & $sResult & "' not found!") Exit EndIf Case BitAND($export_defs, $cEXPORT_DB_NON_SYSTEMS) <> 0 $aDbs = fncArrayExclude($aAllDbs, $aSytemDbs) Case BitAND($export_defs, $cEXPORT_DB_ALL_DATABASES) <> 0 $aDbs = $aAllDbs Case BitAND($export_defs, $cEXPORT_DB_CUSTOM_DATABASES) <> 0 $aDbs = StringSplit(StringStripWS($custom_dbs, 8), ",", 2) Local $sResult = fncItemsInArray($aDbs, $aAllDbs) If @error Then MsgBox(8240, "Error", "Defined custom database name '" & $sResult & "' not found!") Exit EndIf EndSelect ; export Local $sOutFile Local $sFileFirstPart = $export_path & @YEAR & @MON & @MDAY & "." & @HOUR & @MIN & @SEC $sFormat = "%s --lock-all-tables -u %s -p%s -h%s %s > " & """" & "%s" & """" Select Case BitAND($export_defs, $cEXPORT_TO_SINGLE_FILE) <> 0 $sOutFile = FileGetShortName($sFileFirstPart & "_" & _ArrayToString($aDbs, ",") & ".sql") $sExtCmd = StringFormat($sFormat, $sMySqlDmpExe, $dbUsr, $dbPwd, $dbSrv, "-B " & _ _ArrayToString($aDbs, " "), $sOutFile) $CMD = RunWait(@ComSpec & " /c " & $sExtCmd, "", @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD) If FileExists($sOutFile) = 0 Then MsgBox(8208, "Error", "An error occurring during the export..." & $2L & "databases: " & _ _ArrayToString($aDbs, ", ") & @LF & "destination: " & $sOutFile) Exit EndIf Case BitAND($export_defs, $cEXPORT_AS_SEPARATE_FILES) <> 0 For $x = 0 To UBound($aDbs) - 1 $sOutFile = FileGetShortName($sFileFirstPart & "_" & $aDbs[$x] & ".sql") $sExtCmd = StringFormat($sFormat, $sMySqlDmpExe, $dbUsr, $dbPwd, $dbSrv, $aDbs[$x], $sOutFile) $CMD = RunWait(@ComSpec & " /c " & $sExtCmd, "", @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD) If FileExists($sOutFile) = 0 Then MsgBox(8208, "Error", "An error occurring during the export..." & $2L & "database: " & _ $aDbs[$x] & @LF & "destination: " & $sOutFile) Exit EndIf Next EndSelect ; final msg $sFormat = "%s database%s was exported:%s%s%sTo destination:%s%s" $sMsg = StringFormat($sFormat, UBound($aDbs), _iIf(UBound($aDbs) > 1, "s", ""), $2L, "- " & _ _ArrayToString($aDbs, @LF & "- "), $2L, $2L, $export_path) MsgBox(8256, "Done", $sMsg) Exit ; ------------------------------------------------------------------- ; Check if all items from $aSrc are included in $aCmp ; ------------------------------------------------------------------- Func fncItemsInArray($aSrc, $aCmp) Local $bFound, $i, $j For $i = 0 To UBound($aSrc) - 1 $bFound = False For $j = 0 To UBound($aCmp) - 1 If $aSrc[$i] = $aCmp[$j] Then $bFound = True ExitLoop EndIf Next If $bFound = False Then SetError(1) Return $aSrc[$i] EndIf Next Return 1 EndFunc ;==>> fncItemsInArray ; ------------------------------------------------------------------- ; Exclude items from array based on another array ; $iFirstIdx1: ... first index of $aAll ; $iFirstIdx2: ... first index of $aExclude ; ------------------------------------------------------------------- Func fncArrayExclude($aAll, $aExclude, $iFirstIdx1=0, $iFirstIdx2=0) Local $bFound, $i, $j, $aResult[1] For $i = $iFirstIdx1 To UBound($aAll) - 1 $bFound = False For $j = $iFirstIdx2 To UBound($aExclude) - 1 If $aAll[$i] = $aExclude[$j] Then $bFound = True ExitLoop EndIf Next If $bFound = False Then If StringLen($aResult[0]) <> 0 Then ReDim $aResult[UBound($aResult) + 1] EndIf $aResult[UBound($aResult)-1] = $aAll[$i] EndIf Next Return $aResult EndFunc ; ==>> fncArrayExclude ; ------------------------------------------------------------------- ; _Iif from MISC ; ------------------------------------------------------------------- Func _Iif($fTest, $vTrueVal, $vFalseVal) If $fTest Then Return $vTrueVal Else Return $vFalseVal EndIf EndFunc ;==>_Iif Export_MySql_Databases_v1.au3
-
Hi guys, needed something to speed up the backup of the firefox profile, so i did this, works for me just right, and it's here available to anyone who needs it. Obviously gotta thank to everyone who helped me, and had so much patience to help out. Thumbs up for Melba23! This works like this: press backup, it searches for the file extensions.ini in a subfolder of all fixed drives PROGS01 INSTALL If not found, backs it up to 'C:FFProfBackup' The restore function is similar, searches for the same file in the same manner, not found, searches for 'C:FFProfBackup', if found uses that, not found any, won't do anything. Uses a method of deleting the destination dir, and copying the source on it, So use at your risk. Don't blame me if your pc caught fire, or got infested with cockroaches. hehe PS: Uses Melba23 UDF RecFileListToArray that you can get #region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Icon=ResourcesFox.ico #AutoIt3Wrapper_Res_Icon_Add=ResourcesFox.ico #AutoIt3Wrapper_Run_Tidy=n #endregion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <Array.au3> #include <GuiListView.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <ButtonConstants.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <ListViewConstants.au3> #include <RecFileListToArray.au3> Opt("GUIOnEventMode", 1) Opt("TrayAutoPause", 0) Opt("TrayIconDebug", 1) $Form1 = GUICreate("Firefox Profile Backup", 600, 300, 190, 125) GUISetOnEvent($GUI_EVENT_CLOSE, "Close") $Backup = GUICtrlCreateButton("Backup", 10, 265, 75, 25) GUICtrlSetOnEvent($Backup, "Backup") $Restore = GUICtrlCreateButton("Restore", 120, 265, 75, 25) GUICtrlSetOnEvent($Restore, "Restore") $Exit = GUICtrlCreateButton("Exit", 230, 265, 75, 25) GUICtrlSetOnEvent($Exit, "Close") $cListView = GUICtrlCreateListView("Path", 10, 80, 580, 130) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 575) $Label1 = GUICtrlCreateLabel("Profile Folder", 10, 10, 130, 17) $Label2 = GUICtrlCreateLabel("Backup/Restore Folder(s) List", 10, 60, 200, 17) $Label2 = GUICtrlCreateLabel("Backup/Restore Relative Folder", 10, 220, 200, 17) $Input1 = GUICtrlCreateInput(@AppDataDir & 'MozillaFirefox', 10, 30, 580, 21) $Input2 = GUICtrlCreateInput('PROGS', 10, 240, 580, 21) $ProfileDir = GUICtrlRead($Input1) $DestDir = GUICtrlRead($Input2) ;$DefaultBackup = ('C:FFProfBackup') $aArray = DriveGetDrive('FIXED') If @error Then MsgBox(4096, "DriveGetDrive", "It appears an error occurred.") Else For $i = 1 To $aArray[0] $aList = _RecFileListToArray(StringUpper($aArray[$i]) & $DestDir, "extensions.ini", 1, 1, 0, 2) If IsArray($aList) Then For $u = 1 To $aList[0] GUICtrlCreateListViewItem($aList[$u], $cListView) Next EndIf Next EndIf GUISetState(@SW_SHOW) Func Backup() $ProfileDir = GUICtrlRead($Input1) $DestDir = GUICtrlRead($Input2) If FileExists(@AppDataDir & 'MozillaFirefoxProfilesdefault.defaultextensions.ini') Then _GUICtrlListView_DeleteAllItems($cListView) ProgressOn("Progress...", "Working", "") $aArray = DriveGetDrive('FIXED') If @error Then MsgBox(4096, "DriveGetDrive", "It appears an error occurred.") Else For $i = 1 To $aArray[0] $aList = _RecFileListToArray(StringUpper($aArray[$i]) & $DestDir, "extensions.ini", 1, 1, 0, 2) If IsArray($aList) Then For $u = 1 To $aList[0] GUICtrlCreateListViewItem($aList[$u], $cListView) DirRemove(StringTrimRight($aList[$u], 40), 1) Sleep(3000) DirCopy(@AppDataDir & 'MozillaFirefox', StringTrimRight($aList[$u], 40), 1) If FileExists($aList[$u]) Then MsgBox(4096, 'Success!', 'Files copied successfully From: ' & $ProfileDir & ' >>> to >>> ' & (StringTrimRight($aList[$u], 40))) EndIf ProgressSet(50, "50 %", "Working") Next Else MsgBox(4096, "Info", "No Backup found in subdirectories: " & StringUpper($aArray[$i]) & $DestDir) ;DirCopy($ProfileDir, $DefaultBackup, 1) DirCopy($ProfileDir, StringUpper($aArray[$i]) & $DestDir, 1) ;MsgBox(4096, "Info", 'Backup done in: ' & $DefaultBackup & ' >>> And >>> ' & StringUpper($aArray[$i]) & $DestDir) MsgBox(4096, "Info", 'Backup done in: ' & StringUpper($aArray[$i]) & $DestDir) EndIf Next EndIf ProgressSet(100, "100 %", "Done!") Sleep(1000) ProgressOff() Else MsgBox(4096, "Info", "No Profile in: " & $ProfileDir) EndIf EndFunc ;==>Backup Func Restore() $ProfileDir = GUICtrlRead($Input1) $DestDir = GUICtrlRead($Input2) _GUICtrlListView_DeleteAllItems($cListView) ProgressOn("Progress...", "Working", "") $aArray = DriveGetDrive('FIXED') If @error Then MsgBox(4096, "DriveGetDrive", "It appears an error occurred.") Else ProgressSet(50, "50 %", "Working") For $i = 1 To $aArray[0] $aList = _RecFileListToArray(StringUpper($aArray[$i]) & $DestDir, "extensions.ini", 1, 1, 0, 2) If IsArray($aList) Then For $u = 1 To $aList[0] GUICtrlCreateListViewItem($aList[$u], $cListView) DirRemove($ProfileDir, 1) Sleep(2000) DirCopy(StringTrimRight($aList[$u], 40), $ProfileDir, 1) ProgressSet(75, "75 %", "Working") If FileExists(@AppDataDir & 'MozillaFirefoxProfilesdefault.defaultextensions.ini') Then MsgBox(4096, 'Success!', 'Files copied successfully From: ' & (StringTrimRight($aList[$u], 40)) & ' >>> to >>> ' & $ProfileDir) Else MsgBox(4096, "Info", "No Profile in: " & $ProfileDir) EndIf Next Else MsgBox(4096, "Info", "No Backup found in subdirectories: " & StringUpper($aArray[$i]) & $DestDir) ;If FileExists($DefaultBackup & 'Profilesdefault.defaultextensions.ini') Then ;DirCopy($DefaultBackup, $ProfileDir, 1) ;MsgBox(4096, "Info", 'Backup copied from: ' & $DefaultBackup) ;EndIf If FileExists(StringUpper($aArray[$i]) & $DestDir & 'Profilesdefault.defaultextensions.ini') Then DirCopy(StringUpper($aArray[$i]) & $DestDir, $ProfileDir, 1) MsgBox(4096, "Info", 'Backup copied from: ' & StringUpper($aArray[$i]) & $DestDir) EndIf EndIf Next EndIf ProgressSet(100, "100 %", "Done!") Sleep(1000) ProgressOff() EndFunc ;==>Restore Func Close() Exit EndFunc ;==>Close Do Sleep(100) Until $Form1 = 0 Update 1 includes: 1 - input1 is now readable, change path if different 2 - added input2 to set the relative path to save/restore the backup 3 - Removed/commented defaultpath, meaning it no longer saves to C:FFProfBackup, when there's no destination folder set, instead saves to the relative path you wrote. 4 - Included the udf required, icon, and compiled script Download careca.googlecode.com
-
Small rar.exe based backup w/ formated output log
Shane0000 posted a topic in AutoIt Example Scripts
Heres a lil script to run a backup using rar once a day. hotkeys: printscreen to force a backup scroll lock to open last output file pageup to call gui working timer to backup once a day Small gui to save multiple configs Ini to save configs Gathers list of newest files to back up Creates a formated file list / error log So that I can verify at a glance: Appends -error to Log's filename (as required) Appends -noaction to Log's filename (as required) and um thats about it #include <Timers.au3> #include <File.au3> #include <Array.au3> #include <ButtonConstants.au3> #include <ComboConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <GuiComboBox.au3> #include <Constants.au3> $Form1_1 = GUICreate("Form1", 623, 157, 192, 114) $Input1 = GUICtrlCreateInput("c:backup", 8, 0, 545, 21) GUICtrlSetTip(-1, "Location of the back up files.") $Button1 = GUICtrlCreateButton("Locate", 560, 0, 57, 21) $Input2 = GUICtrlCreateInput("Drafting.rar", 8, 24, 545, 21) GUICtrlSetTip(-1, "Filename of the .rar file.") $Button2 = GUICtrlCreateButton("Locate", 560, 24, 57, 21) $Input3 = GUICtrlCreateInput("C:Progra~1WinRARrar.exe", 8, 48, 545, 21) GUICtrlSetTip(-1, "Location of rar/unrar.exe.") $Button3 = GUICtrlCreateButton("Locate", 560, 48, 57, 21) $Input4 = GUICtrlCreateInput("-r -rr5p -x*.bak -x*.dwl -xplot.log -xthumbs.db -x*0_Temp_Saves_0", 8, 72, 545, 21) GUICtrlSetTip(-1, "Rar.exe command line paramaters.") $Combo1 = GUICtrlCreateCombo("h:drafting*.*", 8, 96, 545, 21, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL)) GUICtrlSetTip(-1, "Location of the files to back up.") $Button4 = GUICtrlCreateButton("Locate", 560, 96, 57, 21) $Input5 = GUICtrlCreateInput("1", 8, 120, 48, 21) GUICtrlSetTip(-1, "Wait for the pc to idle before starting back up (In Hours).") $Label1 = GUICtrlCreateLabel("Idle Before Back Up", 60, 120, 80, 32) $Input6 = GUICtrlCreateInput("12", 148, 120, 48, 21) GUICtrlSetTip(-1, "Time out before back up can begin again (In Hours).") $Label2 = GUICtrlCreateLabel("Sleep After Back Up", 200, 120, 72, 32) $Button5 = GUICtrlCreateButton("Cancel", 503, 120, 57, 21) $Button6 = GUICtrlCreateButton("Save", 560, 120, 57, 21) GUICtrlCreateUpdown($input5) GUICtrlCreateUpdown($input6) HotKeySet("{PRINTSCREEN}", "LaunchBackUp") HotKeySet("{SCROLLLOCK}", "OpenOutput") HotKeySet("{PGUP}", "OpenGUI") Local Const $iHour = 3600000 Local $sBackUpDir = 'c:backup' ;Location of new .rar file Local $sRarFile = 'Drafting.rar' ;Name of new .rar file Local $sSRC = 'h:drafting*.*' ;Directory with files to back up Local $sEXE = 'C:Progra~1WinRARrar.exe' ;location of rar.exe Local $iBUStart = 1 ;time to start back-up: 24hr format Local $iBUEnd = 8 ;time to stop trying to start back up: 24hr format Local $iIdleTime = 1*$iHour ;Required Idle Time before starting Back-Up Local $iSleepTime = 10*$iHour Local $sDST = $sBackUpDir & $sRarFile Global $sOutPath Local $iRTime = 0 local $sOPT_User local $iSleepStart = TimerInit() $iSleepTime_Const = 0 $iOn = 0 LoadFromINI() RefreshVars() While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE OpenGUI();Exit Case $Button5 OpenGUI() Case $Button1 $sTmp = FileSelectFolder ( "Select the location for back up files", '' ,7 ) If Not @error Then GuiCtrlSetData($Input1,$sTmp & '') EndIf Case $Button2 $sTmp = FileOpenDialog ( 'Select the rar file to update.'&@CRLF&'Type a file name to create a new rar back up', GUICtrlRead($Input1), "RAR (*.rar)" ,'', "BackUp" ) If Not @error Then $i = StringInStr($sTmp,'') While $i > 0 $sTmp = StringMid($sTmp,$i + 1) $i = StringInStr($sTmp,'') WEnd IF Not StringInStr(StringRight($sTmp,4), '.rar') Then $sTmp = $sTmp&'.rar' EndIf GuiCtrlSetData($Input2,$sTmp) EndIf Case $Button3 ConsoleWrite(StringReplace(GUICtrlRead($Input3),'rar.exe','')& @CRLF) $sTmp = FileOpenDialog ( 'Select the location of rar.exe.', StringReplace(GUICtrlRead($Input3),'rar.exe',''), "RAR (rar.exe)" ,'', "rar.exe" ) If Not @error Then GuiCtrlSetData($Input3,$sTmp) EndIf Case $Button4 $sTmp = FileSelectFolder ( "Select the location of files for back up", '' ,6 ) If Not @error Then _GUICtrlComboBox_AddString($Combo1,$sTmp & '*.*') _GUICtrlComboBox_SelectString($Combo1, $sTmp & '*.*') EndIf Case $Button6 Local $sIni = @ScriptDir & "BackUp.ini" ConsoleWrite("Saving to INI"&@CRLF) Local $aData2[7][2] = [ [0,0] , ["BU_Dir", GUICtrlRead($Input1)],["BU_File", GUICtrlRead($Input2)],["RAR_Exe", GUICtrlRead($Input3)],["RAR_Opt", GUICtrlRead($Input4)], ["Slp_Pre", GUICtrlRead($Input5)], ["Slp_Pst", GUICtrlRead($Input6)] ] IniWriteSection($sIni, _GUICtrlComboBox_GetEditText($Combo1), $aData2) RefreshVars() Case $Combo1 LoadFromINI() EndSwitch ; Sleep(1) If @HOUR > $iBUStart and _ ;add timer and gate for sleep after @HOUR < $iBUEnd and _ $iSleepTime_Const <= timerDiff($iSleepStart) and _ _Timer_GetIdleTime() > $iIdleTime then ;OR NOT FileExists($sDST) then ;use to create back-up @ runtime Main() $iSleepStart = TimerInit() $iSleepTime_Const = $iSleepTime ConsoleWrite(_Timer_GetIdleTime()&@TAB&$iIdleTime&@TAB&$iSleepTime_Const&@TAB&timerDiff($iSleepStart)&@CRLF) EndIf ;ConsoleWrite(_Timer_GetIdleTime()&@TAB&$iIdleTime&@TAB&$iSleepTime_Const&@TAB&timerDiff($iSleepStart)&@CRLF) WEnd Func OpenGUI() If $iOn Then GUISetState(@SW_HIDE) $iOn = 0 Else GUISetState(@SW_SHOW) $iOn = 1 EndIf EndFunc Func OpenOutput () If StringLen ($sOutPath) > 0 Then Run('notepad.exe ' & $sOutPath) Else MsgBox(0,'Alert','No backup log generated.') ;do a file open dialog in backup dir EndIf EndFunc Func LaunchBackUp() $iReturn = MsgBox(4,'Alert','Run BackUp Now?') If $iReturn = 7 then MsgBox(0,'Alert','BackUp Cancelled',3) Else Main() EndIf EndFunc Func Main() RefreshVars() ConsoleWrite('Func Main() ' & @CRLF) Local $iDoUpdate If Not FileExists($sDST) Then ;add files to new .rar $iDoUpdate = 0 $sOPT = ' a -tl ' & $sOPT_User & ' -ilog' & $sBackUpDir & 'error.log ' & $sDST & ' ' & $sSRC ; command line options here Else ;update/add files to existing .rar If Not FileExists($sBackUpDir & 'UpdateList.lst') Then $iDoUpdate = CreateFileList($sBackUpDir,$sDST,$sSRC) EndIf $sOPT = ' u -tl ' & $sOPT_User & ' -ilog' & $sBackUpDir & 'error.log ' & $sDST & ' @' & $sBackUpDir & 'UpdateList.lst' ;& $sSRC ; command line options here EndIf ConsoleWrite('$sOPT ' & $sOPT & @CRLF) If $iDoUpdate Then Local $aReturnLogs = DoBackUp ($sEXE , $sOPT , $sBackUpDir) $aLog = FormatLog($aReturnLogs[2]) $aLogErr = $aReturnLogs[3] $iFileCount = CountFiles($aLog) $sOutPath = Create_File($aLog,$aLogErr,Time_Convert($aReturnLogs[1]),$aReturnLogs[0],$iFileCount,$sBackUpDir,$sRarFile) ;FileDelete($sBackUpDir & 'UpdateList.Lst') Else MsgBox(0,"Alert","No files to update.",20) Dim $aDumLog[1] = ["WARNING: No files"] Create_File($aDumLog,default,0,10,0,$sBackUpDir,$sRarFile) EndIf EndFunc Func DoBackUp ($sEXE , $sOPT , $sBackUpDir) ConsoleWrite('Func DoBackUp ($sEXE , $sOPT , $sBackUpDir)' & @CRLF) Local $aLog Local $aLogErr Local $aReturn[4] Local $iRStart = _Timer_Init() $aReturn[0] = RunWait(@ComSpec & ' /c ' & $sEXE & ' ' & $sOPT & ' > ' & $sBackUpDir & 'output.tmp', @TempDir, @SW_HIDE) $aReturn[1] = _Timer_Diff($iRStart) _FileReadToArray($sBackUpDir & 'output.tmp',$aLog) FIleDelete($sBackUpDir & 'output.tmp') $aReturn[2] = $aLog If FileExists ($sBackUpDir & 'error.log') Then _FileReadToArray($sBackUpDir & 'error.log',$aLogErr) FIleDelete($sBackUpDir & 'error.log') $aReturn[3] = $aLogErr Else $aReturn[3] = Default EndIf Return $aReturn EndFunc Func Time_Convert($iTimeDiff) ConsoleWrite('Func Time_Convert($iTimeDiff)' & @CRLF) ; ; Converts TimerDiff (ms) to HMS format ; ; $TimeDiff = Integer; Milliseconds ; $hrs = 0 $min = 0 $sec= Round($iTimeDiff/1000,0) if $sec>59 then $hrs = int($sec / 3600) $sec = $sec - $hrs * 3600 $min = int($sec / 60) $sec = $sec - $min * 60 EndIf return $hrs & "h" & $min & "m" & $sec & "s" EndFunc Func Create_Header($theLog,$theTime,$theExit,$theFileCount) ConsoleWrite('Func Create_Header($theLog,$theTime,$theExit,$theFileCount)' & @CRLF) ; ; Creates Output File Header ; ; $theLog = Array; Output Data ; $theTime = Integer; Runtime for Rar.exe in ms ; $theExit = Integer; Exit Code for Rar.exe ; $theFileCount = Integer; Return from CountFiles() ; Local $sExitDesc Local $aExitDesc[11] = ['Successful operation.', _ 'Warning. Non fatal error(s) occurred.', _ 'A fatal error occurred.', _ 'Invalid CRC32 control sum. Data is damaged.', _ 'Attempt to modify a locked archive.', _ 'Write error.', _ 'File open error.', _ 'Wrong command line option.', _ 'Not enough memory.', _ 'File create error.', _ 'No files matching the specified mask were found.'] _ArrayInsert($theLog, 0) _ArrayInsert($theLog, 0) _ArrayInsert($theLog, 0) If $theExit > Ubound($aExitDesc) Then $sExitDesc = 'User break.' Else $sExitDesc = $aExitDesc[$theExit] EndIf $theLog[0] = 'Update Time: ' & $theTime & @TAB & 'File Count: '& $theFileCount $theLog[1] = 'Exit Code: ' & $theExit & ' ' & $sExitDesc Return $theLog EndFunc Func Create_File($theLog,$theErrorLog,$theTime,$theExitCode,$theFileCount,$theLocation,$theName) ConsoleWrite('Func Create_File($theLog,$theErrorLog,$theTime,$theExitCode,$theFileCount,$theLocation,$theName)' & @CRLF) ; ; Creates Output File ; ; $theLog = Array; Output from Rar.exe ; $theErrorLog = Array; Error Output from Rar.exe ; $theTime = Integer; Runtime for Rar.exe in ms ; $theExit = Integer; Exit Code for Rar.exe ; $theFileCount = Integer; Return from CountFiles() ; $theLocation = String; Path to backup dir ; $theName = String; Filename of .rar file ; Local $theData, $theSuffix = '' If _ArraySearch($theLog,"WARNING: No files") > -1 Then $theSuffix = '-NoAction' Dim $theLog[3] = ['','','WARNING: No files'] EndIf If IsArray($theErrorLog) Then ;put errors at top of file $theSuffix &= '-Errors' $theErrorLog[0] = 'Errors: ' $TheData = Create_Header($theErrorLog,$theTime,$theExitCode,$theFileCount) _ArrayConcatenate($TheData,$theLog) ;add Rar output to the Error Log Else $TheData = Create_Header($theLog,$theTime,$theExitCode,$theFileCount) EndIf Local $sFile = $theLocation & StringTrimRight ( $theName, 4 ) & '_' & @Mon & '-' & @MDay & '-' & @Year & $theSuffix & '.log' _FileWriteFromArray($sFile,$TheData) Return $sFile EndFunc Func FormatLog($theLog) ConsoleWrite('Func FormatLog($theLog)' & @CRLF) ; ; Formats Output from Rar.exe ; Removes: Backspace Chacters, ' OK ', 'xxx%', and empty elements ; ; $theLog = Array; Output from Rar.exe ; Local $PerLoc, $TMP If _ArraySearch($theLog,"WARNING: No files") > -1 Then Return $theLog EndIf While StringInStr($theLog[0],"ing archive") < 1 ;remove Rar header upto either 'UPDATing ...' Or 'ADDing ...' _ArrayDelete($theLog,0) WEnd For $i = 0 to UBound($theLog)-1 $TMP = StringReplace($theLog[$i],'',"") ;removes BackSpace character codes $TMP = StringReplace($TMP, ' OK ','') ;removes OK from End Of Line while StringInStr($TMP,"%") ;removes xxx% $PerLoc = StringInStr($TMP,"%") $TMP = StringReplace($TMP,StringMid($TMP,$PerLoc-3,4),"") wend $theLog[$i] = $TMP Next Return $theLog EndFunc Func CountFiles($theFileList) ConsoleWrite('Func CountFiles($theFileList)' & @CRLF) ; ; Creates Output File Header ; ; $theFileList = Array; Output from Rar.exe ; Local $CntAdd, $CntUpd $CntAdd = _ArrayFindAll($theFileList,'Adding ','','','',1) $CntUpd = _ArrayFindAll($theFileList,'Updating ','','','',1) Return Ubound($CntAdd)+Ubound($CntUpd) EndFunc Func CreateFileList($sOutPath,$sTheFile,$sSRC) ; ; Finds New Files to BackUp ; ; $sOutPath = String; Output directory ; $sTheFile = String; the file to use for time compare ; $sSRC = String; The source for files to be backed up ; ; !!!!!!!! -tl !!!!!!! This must stay in the options for rar.exe ; This sets the rar's time to the most recently updated file ; Anything newer than that file gets updated ; ConsoleWrite('Func CreateFileList($sOutPath,$sTheFile)' & @CRLF) Local $aFileLog[1] Local $aFinalFileList[1] Local $sTempDir Local $aCurDate $aStdTime = FileGetTime ($sTheFile); Get the latest file time from rar file _ArrayDelete($aStdTime,5) $aStdTime[4] = $aStdTime[3] $aStdTime[3] = $aStdTime[0] _ArrayDelete($aStdTime,0) Local $sCommand = 'dir '&$sSRC&' /T:w /x /s /O:d > ' & $sOutPath & 'UpdateList.lst' ConsoleWrite($sCommand& @CRLF) RunWait(@ComSpec & ' /c ' & $sCommand, @TempDir, @SW_HIDE) _FileReadToArray($sOutPath & 'UpdateList.lst',$aFileLog) FileDelete($sOutPath & 'UpdateList.lst') While StringInStr($aFileLog[0]," Directory of") < 1 ;delete array until first directory structure _ArrayDelete($aFileLog,0) WEnd For $i = 0 to Ubound($aFileLog) -1 If StringInStr($aFileLog[$i],'Directory of ') > 0 Then ;Set File Directory $sTempDir = StringReplace($aFileLog[$i],' Directory of ','') & '' ;ConsoleWrite('$sTempDir' & $i & ' ' & $sTempDir & @CRLF) EndIf If StringInStr($aFileLog[$i],'/' & $aStdTime[2] ) > 0 And _ ; If file was made in same year as rar file StringInStr($aFileLog[$i],"<DIR>") < 1 then ; and is not a directory $aCurDate = StringSplit( StringLeft($aFileLog[$i],10),'/',2) ;capture the date of the file save If StringMid( $aFileLog[$i], 19, 2 ) = "PM" Then $iHalfDay = 12 Else $iHalfDay = 0 EndIf _arrayAdd($aCurDate,StringMid( $aFileLog[$i], 13, 2 ) + $iHalfDay) ;capture the hour of the file save If $aCurDate[0] >= $aStdTime[0] Then If $aCurDate[1] > $aStdTime[1] OR ($aCurDate[1] = $aStdTime[1] And $aCurDate[3] > $aStdTime[3]) Then ;Add File if newer than backup file _ArrayAdd($aFinalFileList,FileGetShortName($sTempDir& StringMid($aFileLog[$i],53))) ;ConsoleWrite('Dates '& _ArrayToString($aCurDate) & ' ### ' & _ArrayToString( $aStdTime ) & @CRLF) EndIf EndIf EndIf Next ;_ArrayDisplay($aFinalFileList) _ArrayDelete($aFinalFileList,0) _FileWriteFromArray(FileGetShortName($sOutPath & "UpdateList.lst"),$aFinalFileList) Return IsArray($aFinalFileList) EndFunc Func LoadFromINI() ; ; Loads Values from INI based on Combobox selection ; ; $theFileList = Array; Output from Rar.exe ; ConsoleWrite("LoadFromINI "&@CRLF) If FileExists(@ScriptDir & "BackUp.ini" ) Then $aIniSecNames = IniReadSectionNames ( @ScriptDir & "BackUp.ini" ) If Not @error Then _ArrayDelete($aIniSecNames,0) _GUICtrlComboBox_DeleteString($Combo1,0) GUICtrlSetData($Combo1,StringReplace(_ArrayToString($aIniSecNames),"?",''),$aIniSecNames[1]) $aIniValues = IniReadSection ( @ScriptDir & "BackUp.ini", _GUICtrlComboBox_GetEditText($Combo1) ) If Not @error Then GUICtrlSetData($Input1,$aIniValues[1][1]) GUICtrlSetData($Input2,$aIniValues[2][1]) GUICtrlSetData($Input3,$aIniValues[3][1]) GUICtrlSetData($Input4,$aIniValues[4][1]) GUICtrlSetData($Input5,$aIniValues[5][1]) GUICtrlSetData($Input6,$aIniValues[6][1]) ;ConsoleWrite($aIniValues[0][1]&@CRLF) EndIf EndIf EndIf EndFunc Func RefreshVars() ConsoleWrite("RefreshVars "&@CRLF) $sBackUpDir = GuiCtrlRead($Input1) $sRarFile = GuiCtrlRead($Input2) $sEXE = GuiCtrlRead($Input3) $sOPT_User = GuiCtrlRead($Input4) $iIdleTime = number(GUICtrlRead($Input5))*$iHour $sSRC = StringTrimRight(_GUICtrlComboBox_GetEditText($Combo1),1) $iSleepTime = GUICtrlRead($Input6)*$iHour ;$iBUStart = ; redo gui to add these ;$iBUEnd = $iSleepTime_Const = $iSleepTime EndFunc ;to do ; make newly added, but older than backup date, file list to comparing with rar list; ; add BUStart & BUEnd to GUI and INI routine ; ; add option to cycle through multiple configurations at backup time (create multiple backups); ; add header to Func Main() RefreshVars;Sample output from : Drafting_08-18-2012-Errors.log Update Time: 8h31m43s File Count: 136519 Exit Code: 6 File open error. Errors:-------- 18 Aug 2012, archive c:backupDrafting.rar 13:30:23 Cannot open h:draftingHouseElec_Panels.dwg 13:30:23 The process cannot access the file because it is being used by another process. 13:30:23 Cannot open h:draftingHouseElec_Panels.dwl2 13:30:23 The process cannot access the file because it is being used by another process. Creating archive c:backupDrafting.rar Adding h:drafting0_DocsAcad 2007 Invoice.PDF Adding h:drafting0_DocsAcadLT2002.txt Adding h:drafting0_DocsAutoCAD 2007 Reciept.pdf Adding h:drafting0_DocsFull_JobLog-2006.xlsBackUp_0.5.au3 BackUp_0.6a.au3 BackUp_0.7.au3 -
TinyBackupBox : Do a Backup of folders you want to a local/external drive/directory by using Robocopy. A Big Thank to Yashield for TVExplorer.au3 and WinApiEx.au3 Includes needed : >TVExplorer.au3 and >WinApiEx.au3 * Left Treeview : Check all folders Checkboxes you want to backup. Hold Shift key when clicking a first child Checkbox will check all other child Checkboxes. A right click on a parent item will uncheck all his child Checkboxes. * Right Treeview : A left click for select Backup Directory. A right click menu on an item for create a new sub-folder which you can give the name you want. This new sub-folder will be created and added as child item of the item you have right clicked. * Start Button : A Click on Start Button will start backup normally. Hold Shift key when clicking it will start backup on Idle Mode. Idle Mode is used for start or resume backup after a period of user inactivity (that you can set by tray menu) and will pause current backup if not idle. * Stop Button : A click on Stop Button will Pause backup, and any changes will affect the backup when resume it. You can resume a current backup by Re-clicking Start Button. Hold Shift key when clicking Stop Button will totally Cancel current backup. In Idle mode Stop Button is inactive until you Hold Shift key and click for Cancel current backup. * Refresh Button : A Click will refresh both treeviews and set them to the previous selections you have done. Hold Shift key when clicking it will refresh both treeview and set them to the root. * Tray Menu : By Default Robocopy copy only new files, so i add the possibility to _ delete previous existing dir. _ delete destination files and dirs that no longer exists in source. _ Preserve all Attributes. _ Show Robocopy Console window. _ Set Idle Time Delay. _ Open Backup Dir. Update of 2011-12-21 Previous downloads : 103 source and executable are available in the Download Section minimalist but handy ! Hope you like it ! And do not forget to create backup periodically !