Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Zip a dated folder 2

Status
Not open for further replies.

AlohaRoss

IS-IT--Management
May 8, 2009
1,200
0
36
TH
What is the best batch command to at EOD take the new dated folder and create zip file. The zip file can be the same name each day as it is then being emailed out. I have the email portion worked out. Its the correct command to zip a dated folder I struggle with.
My aloha folder is
d:\bootdrv\aloha

Any help would be nice

AlohaRoss
An Aloha POS 3rd Party support Solution company.
PM me on Reddit
 
Windows 8 and above have it naturally. For 7 and below, you can use powershell if you add this to a batch file.
powershell.exe -nologo -noprofile -command "& { Add-Type -A 'System.IO.Compression.FileSystem'; [IO.Compression.ZipFile]::ExtractToDirectory('Aloha.zip', 'bar'); }"

The issue is the above probably just names it to a single zip file. If you instead can call something like 7zip from command line, you will keep the original folder name and be set for success.
 
this was my solution
as part of EOD it runs this via winhook
xcopy D:\bootdrv\aloha e:\alohazip /M /E /G /H /Y

E drive is an external drive. Then for more cloud backup I added this folder to Google drive watch folder. Now I have an on and offsite backup

AlohaRoss
An Aloha POS 3rd Party support Solution company.
PM me on Reddit
 
I know this is a little late but this does exactly what you asked
I am no longer working with aloha we have moved to onePOS
(I hate onePOS, but that's what I am stuck with)

This worked fine with Aloha 6.7 2 years ago and as long as they still have winhook.bat should work today

If I understand last post, it seems to me that what you are doing would archive the whole aloha folder every day
For me that would be thousands of dated folders every day, LOTS of data EVERY day


I will show you how I did it on Windows 7 32bit and there are 7-zip versions that run in batch
files on Windows 10 64bit (syntax may change)

Aloha runs this automatically after each end of day via the Aloha winhook.bat
If you use Aloha Gift Cards there may be another batch file name that runs, it will be listed
in the system area of Aloha Manager. Sometimes that file is called from winhook.bat

I used an idrive account to backup my folder defined by archdir (archdir is set in winhook.bat)
In that folder I place a zip file of whole aloha folder made manually with a name like:

2012-01-31FULL.ZIP This file is large but only gets backed up once (until you replace it after an upgrade)

(7-zip filemanager is an excellent open source way to do this I have also used totalcommander)

idrive backup (or other cloud backup of your choice) should archive the archdir folder each day
this would be a tiny amount daily, just the 1 zipped dated folder which also contains edc.ini
(I found out the hard way to ALWAYS have a current copy of edc.ini)


winhook.bat is in the bin folder, when it is executed after EOD it knows the latest dated folder

------------- winhook.bat in the bin folder---------

rem this uses 7-zip (7z.exe) to create zip archive (z-zip is easier to find than info-zip and pkzip)
rem you do not have to install 7-zip but you do need to place a copy of 7z.exe in your Windows
rem folder or windows\system32 folder unless you want to include the full path to 7z.exe on command line
rem 7z.exe is found in the folder that z-zip is installed into

rem *** Define your archive drive and folder ***

rem---- beware, I have seen problems with folder nesting for the archive drive like c:\backup\aloha
rem---- so I would only set this to a drive letter or like the following a drive letter and 1 folder deep
rem---- this may not be a problem if you create the folders before you run the bat file

SET ARCHDIR=D:\BACKUP

rem---- you can also use a usb drive "hint" disk management can make a USB drive appear in an
rem---- empty NTFS folder so you alway know it's drive designation (see change drive letters and paths)

rem --------------- cleanup dated folder --------------------
rem *** Delete unneeded CDX files in dated subdirs ***

DEL %IBERDIR%\%1\*.CDX

rem ---------- copy edc.ini to the dated folder (I name it edcini.txt)-----------------

copy /Y %IBERDIR%\EDC\EDC.INI %IBERDIR%\%1\EDCINI.TXT


rem --------------- zip only the dated folder this will also include the folder in the archive---------

rem *** Archive dated sub to archive drive ***
rem--- the following may seem a little odd but it is the only way I have been able to get a
rem--- zip file with the folder inside too (as well as the files in it)
rem--- this makes things MUCH easier if you ever need to restore a LOT of zipped dated folders
rem--- this assumes iberdir is located on D:
D:
cd\
cd %iberdir%

7z.EXE a -tzip -r %ARCHDIR%\%1.ZIP %1\*.*

rem --- this is the end of the lines you need to add to winhook.bat


I had a client with over 6 years of data archived this way in a free 2GB idrive account
EOD ran at 1am and I had idrive do the backup at 3am 5am and 5pm "just to be sure"
The daily backup never had to move over 3MB

You can test this on a dated folder ie 20170525 run winhook.bat 20170525 from D:\ALOHA\BIN
 
just to be clear, each night when the batch file above runs, a zip file named the same as the dated folder for that date will be created in archdir

on May 5 2017 a zip file named 20170505.zip will be created containing a folder named 20170505

that folder will contain all the files that were in that dated folder
 
Using the Xcopy and the switches I have, I am using the archive bit. SO it just copies new folders and files. It also will pick up any dated folders that have been modified for clock in adjustments. So it is really a true backup with modified data as it happens each day. After a few days, I can report, it has worked perfectly. I can now with little effort have a new server in place with all files without needing to unzip each folder. Just install google drive on a new machine, and have it restore to \bootdrv\aloha, reinstall Aloha and done.

Thanks for the samples on how to zip. I did give it a try and have made a few notes for others

SET ARCHDIR=D:\BACKUP
DEL %IBERDIR%\%1\*.CDX ([highlight #FCE94F]not needed if you dont have aloha copy cdx and tdx at eod)[/highlight]
copy /Y %IBERDIR%\EDC\EDC.INI %IBERDIR%\%1\EDCINI.TXT [highlight #FCE94F](Change path for EDC if your edc is saved outside of shared bootrv folder[/highlight]
7z.EXE a -tzip -r %ARCHDIR%\%1.ZIP %1\*.* [highlight #FCE94F]For this to work, 7z.exe needs to be in the bin folder of Aloha[/highlight]

AlohaRoss
An Aloha POS 3rd Party support Solution company.
PM me on Reddit
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top