PDA

View Full Version : ioBackup


Mr_X
07-18-2004, 10:03 AM
It backups user files (etc, users, groups, scripts) and ioFTPD.ini into a rar file with a password and send it to another FTP or to a SMB share.

Script page (http://www.inicom.net/pages/en.ioftpd-scripts.php?id=115)

Changelog:

v1.2.1
- Didn't recursive copy, fixed now (thx to lefkas)

v1.2
- Recursive copy of dirs
- Change RARPATH to EXEPATH (there's 2 exe now: robocopy.exe and rar.exe)
- Backup now also scripts dir
- Added TODO.txt

v1.1.3
- Updated rar (3.42) and readme.txt

v1.1.2
- if env var windir doesn't exist, testing SystemRoot (same value)

v1.1.1
- Corrected some bugs and readme

v1.1
- Added the possibility to send backup to a network drive

v1.0
- initial release

djrob
07-20-2004, 05:16 AM
Looks promising but i can't get it to work. Followed the readme but when doing "site backup" all i get is command sucessful and that's it. No backup rar-file anywhere :(

Mr_X
07-20-2004, 01:01 PM
It's logical you get command successful, you'll get everytime this. I make the script running in background (if it's not running in background, you'll have to wait at least 3-4 seconds (time to rar and connect to the ftp and send the file) before sending another command to the FTP.
The reason because it doesn't work is that perhaps your FTP is down. I don't manage ftp errors in this version, this will be added in v2.0 (that will be totally rewritten in C).
To test it, remove "echo !detach 0" at line 5 (you will see FTP session); You will have to wait about 3-4 seconds before you see anything. Check also if the login given to the script has write permission.

djrob
07-21-2004, 06:25 AM
Both the ftp that's being backup'd and the one it's beeing send to is ofcourse up and running. I've edited backup.bat's rarpath (which according to readme is the only thing to edit there) and added custom command in ioftpd.ini like this:

backup = EXEC ..\scripts\backup.bat testing myftp.something.com 5867 user pass folderonremoteftp

first try gave me:

R] site backup
[R] 200-Det finns redan en fil eller underkatalog med namnet backup.
[R] 200-Det finns redan en fil eller underkatalog med namnet etc.
[R] 200-Det finns redan en fil eller underkatalog med namnet users.
[R] 200-Det finns redan en fil eller underkatalog med namnet groups.
[R] 200-Det finns redan en fil eller underkatalog med namnet ini.
[R] 200-Parameters: SMB/FTP WhereToSend [Port] Login Pass Directory
[R] 200-
[R] 200-SMB/FTP Send the file via a network drive or FTP
[R] 200-WhereToSend FTP where to send backup
[R] 200-Port Port of the FTP even if it's 21.
[R] 200- Don't give it if sending via network drive
[R] 200-Login Login of the FTP
[R] 200-Pass FTP and archive password
[R] 200-Directory Where to put archive
[R] 200 Command successful.

Then i tried 2 more and both times got:
[L] site backup
[L] 500 SITE backup: Command not understood.
[L] site backup
[L] 500 SITE backup: Command not understood.

So i'm sorry to say once more... it's not working :(

EDIT: it is doing something though.... just found a backup folder inside my ioFTPD folder with the files that's supposed to be backup'd. What's it doing there i don't know and why it's not in rar i dunno eihter :p

EDIT 2: What's a SMB??

Mr_X
07-21-2004, 12:22 PM
SMB means Server Message Block. It's the protocol that windows (and Samba) use to connect network drive (to a directory you shared) and transfer files

You forgot to add FTP to the line (as I see your first try)
backup = EXEC ..\scripts\backup.bat testing FTP myftp.something.com 5867 user pass folderonremoteftp

You also pointed to a bug (something I forgot: deleting old backup directory if script failed). i also found 1 error.
Everything is corrected in v1.1.1

Strange, I also got once (for me it's SITE BACKUPTO):
[L] site backupto (all parameters)
[L] 500 SITE backup: Command not understood.

I cannot explain why, I think that's an ioFTPD error.
When you got this, try reconnect to the FTP

edit: there was also some errors in readme, sorry (corrected)

djrob
07-21-2004, 01:08 PM
I've changed the line in ioftpd.ini to:

backup = EXEC ..\scripts\backup.bat testing FTP myftp.something.com 5867 user pass folderonremoteftp

Still don't work though :(
Get this now:

[R] site backup
[R] 200-Det gâ€_r inte att hitta filen. <-- can't find file
[R] 200-Det gâ€_r inte att hitta s”kv„gen. <-- can't find path
[R] 200 Command successful.

I have rar.exe in scripts folder so this should be correct:
set RARPATH=..\scripts\

Perhaps it's my swedish windows it doesn't like or something..?

Mr_X
07-26-2004, 01:59 PM
do not put \ at the end of RARPATH. It's the reason because script fails. It should be RARPATH=..\scripts

djrob
07-27-2004, 12:05 PM
Nope, still the same i'm afraid :(

[R] site backup
[R] 200-Det g‟r inte att hitta filen. <-- can't find file
[R] 200-Det g‟r inte att hitta s”kv„gen. <-- can't find path
[R] 200 Command successful.

backup.bat:
@echo off
set RARPATH=..\scripts
set NETWORKDRIVE=B:
if not exist %RARPATH%\rar.exe goto rarnotexist
if %2==FTP goto FTPT
if %2==ftp goto FTPT
if %6.==. goto usage
goto paramok
:FTPT
if %7.==. goto usage
:paramok

REM Make the script running in background. Delete previous line
REM if you want to see FTP session or network drive copying
:updir
cd ..
if not exist .\system\ioFTPD.exe goto updir
rd /s /q backup
md backup\etc
cd backup
md users
md groups
md ini
copy ..\etc\*.* .\etc >nul
copy ..\users\*.* .\users >nul
copy ..\groups\*.* .\groups >nul
copy ..\system\*.ini .\ini >nul
%RARPATH%\rar.exe a -s -inul -hp%6 %1.rar etc
%RARPATH%\rar.exe a -s -inul -hp%6 %1.rar users
%RARPATH%\rar.exe a -s -inul -hp%6 %1.rar groups
%RARPATH%\rar.exe a -s -inul -hp%6 %1.rar ini
if %2==SMB goto NetDrive
if %2==smb goto NetDrive
if %2==FTP goto ViaFTP
if %2==ftp goto ViaFTP
goto usage
:ViaFTP
echo open %3 %4>script.txt
echo %5 >>script.txt
echo %6 >>script.txt
echo cd %7 >> script.txt
echo del %1.rar >>script.txt
echo put %1.rar >>script.txt
echo bye >>script.txt
%windir%\system32\ftp.exe -s:script.txt
goto end
:NetDrive
net use %NETWORKDRIVE% %3 %6 /user:%5
net use %NETWORKDRIVE% %3 "" /user:%5
copy %1.rar %NETWORKDRIVE%
net use %NETWORKDRIVE% /delete /yes
goto end
:usage
if %1.==. goto notfirst
echo Parameters: SMB/FTP WhereToSend [Port] Login Pass Directory
echo.
goto cont
:notfirst
echo Usage: %0 FTPName SMB/FTP WhereToSend Port Login Pass Directory
echo.
echo FTPName Archive will have this name (pay attention, old one will be deleted)
:cont
echo SMB/FTP Send the file via a network drive (SMB) or FTP
echo WhereToSend Address where to send backup
echo if using SMB use \\adresse\share
echo Port Port of the FTP even if it's 21.
echo Don't give it if sending via network drive
echo Login Login of the FTP
echo Pass FTP and archive password
echo Directory Where to put archive (do not put any '/' or '\' at the begining)
goto end
:rarnotexist
echo Edit this script's second line and set RARPATH (directory where is rar.exe)
:end
cd..
if exist .\system\ioFTPD.exe rd /s /q backup

ioftpd.ini:
backup = EXEC ..\scripts\backup.bat testar FTP 192.168.0.4 5678 djrob password PRIVAT
(trying local ftp now)

Mr_X
07-27-2004, 02:50 PM
Do you have WINDIR env var in ioftpd.env ?

djrob
07-27-2004, 03:14 PM
Nope. Says nothing about that in either ioftpd or iobanana downloads. Here's my .env:

SYSTEMPATH=%[$path]
VIRTUALPATH=%[$pwd]
STATSSECTION=%[$statssection]
CREDITSECTION=%[$creditsection]
SPEED=%.[speed]
USER=%[$user]
UID=%[$uid]
GID=%[$gid]
GROUP=%[$group]
GROUPS=%[group]
IDENT=%[$ident]
IP=%[$ip]
CREDITS=%[credits(mega)]
FLAGS=%[$flags]
TAGLINE=%[$unfo]
COMSPEC=%[environment(COMSPEC)]
PATH=%[environment(PATH)]
SYSTEMROOT=%[environment(SYSTEMROOT)]
SYSTEMDRIVE=%[environment(SYSTEMDRIVE)]

ChipMunk666
07-28-2004, 12:06 AM
maybe you should add it and try it ;)

djrob
07-28-2004, 03:52 AM
Originally posted by ChipMunk
maybe you should add it and try it ;)

Of course... if i only knew how it looks :p

Mr_X
07-28-2004, 01:00 PM
You don't need to add it. v1.1.2 try Windir env var and if it didn't exist, it try SystemRoot

djrob
07-28-2004, 02:15 PM
A bit closer i think.... got this 0byte file on remote ftp: testar.rar.bad
And once again i get a backup folder inside my ioftpd dir :eek:

I give up now and keep doing manual backup i think...

oh, and my ioftpd.env looks like this:

SYSTEMPATH=%[$path]
VIRTUALPATH=%[$pwd]
STATSSECTION=%[$statssection]
CREDITSECTION=%[$creditsection]
SPEED=%.[speed]
USER=%[$user]
UID=%[$uid]
GID=%[$gid]
GROUP=%[$group]
GROUPS=%[group]
IDENT=%[$ident]
IP=%[$ip]
CREDITS=%[credits(mega)]
FLAGS=%[$flags]
TAGLINE=%[$unfo]
COMSPEC=%[environment(COMSPEC)]
PATH=%[environment(PATH)]
SYSTEMROOT=%[environment(SYSTEMROOT)]
SYSTEMDRIVE=%[environment(SYSTEMDRIVE)]

Good luck with it though :)

zpr
07-30-2004, 11:45 AM
doesnt work here neither

i dont have windir in .env but systemroot

0 byte file on destination ftp and no clue how to sent it to another drive

F30R
08-23-2004, 04:43 AM
[11:41:19] site backup
[11:41:21] 200-The system cannot find the file specified.
[11:41:21] 200-Invalid command.
[11:41:21] 200-Invalid command.
[11:41:21] 200-Not connected.
[11:41:21] 200-Not connected.
[11:41:21] 200-Not connected.
[11:41:21] 200-open xxx 21
[11:41:21] 200-backup
[11:41:21] 200-backup
[11:41:21] 200-cd c:\
[11:41:21] 200-del test.rar
[11:41:21] 200-put test.rar
[11:41:21] 200-bye
[11:41:21] 200-> ftp: socket :Unknown error number
[11:41:21] 200 Command successful.


my bat is :

@echo off
set RARPATH=c:\server\scripts
set NETWORKDRIVE=X:
if not exist %RARPATH%\rar.exe goto rarnotexist
if %2==FTP goto FTPT
if %2==ftp goto FTPT
if %6.==. goto usage
goto paramok
:FTPT
if %7.==. goto usage
:paramok
REM Make the script running in background. Delete previous line
REM if you want to see FTP session or network drive copying
:updir
cd ..
if not exist c:\server\system\ioFTPD.exe goto updir
rd /s /q backup
md backup\etc
cd backup
md users
md groups
md ini
copy ..\etc\*.* .\etc >nul
copy ..\users\*.* .\users >nul
copy ..\groups\*.* .\groups >nul
copy ..\system\*.ini .\ini >nul
%RARPATH%\rar.exe a -s -inul -hp%6 %1.rar etc
%RARPATH%\rar.exe a -s -inul -hp%6 %1.rar users
%RARPATH%\rar.exe a -s -inul -hp%6 %1.rar groups
%RARPATH%\rar.exe a -s -inul -hp%6 %1.rar ini
if %2==SMB goto NetDrive
if %2==smb goto NetDrive
if %2==FTP goto ViaFTP
if %2==ftp goto ViaFTP
goto usage
:ViaFTP
echo open %3 %4>script.txt
echo %5 >>script.txt
echo %6 >>script.txt
echo cd %7 >> script.txt
echo del %1.rar >>script.txt
echo put %1.rar >>script.txt
echo bye >>script.txt
c:\winnt\system32\ftp.exe -s:script.txt
goto end
:NetDrive
net use %NETWORKDRIVE% %3 %6 /user:%5
net use %NETWORKDRIVE% %3 "" /user:%5
copy %1.rar %NETWORKDRIVE%
net use %NETWORKDRIVE% /delete /yes
goto end
:usage
if %1.==. goto notfirst
echo Parameters: SMB/FTP WhereToSend [Port] Login Pass Directory
echo.
goto cont
:notfirst
echo Usage: %0 FTPName SMB/FTP WhereToSend Port Login Pass Directory
echo.
echo FTPName Archive will have this name (pay attention, old one will be deleted)
:cont
echo SMB/FTP Send the file via a network drive (SMB) or FTP
echo WhereToSend Address where to send backup
echo if using SMB use \\adresse\share
echo Port Port of the FTP even if it's 21.
echo Don't give it if sending via network drive
echo Login Login of the FTP
echo Pass FTP and archive password
echo Directory Where to put archive (do not put any '/' or '\' at the begining)
goto end
:rarnotexist
echo Edit this script's second line and set RARPATH (directory where is rar.exe)
:end
cd..
if exist .\system\ioFTPD.exe rd /s /q backup

maX1mus
10-04-2005, 03:33 PM
Wow nice script :)
Works flawless for us..
I have a question Mr_X, is it possible in an not too hard way to make folders inside the created folders..?
What im thinking of is making the structure of the backup as identical to the install as possible.
For easier use if you need to recover settings.
For example,
ioFTPD
ioFTPD\scripts
ioFTPD\scripts\warchive\*.*
ioFTPD\scripts\ioA\*.*
etc
I tried a lot with cd md and back but no luck :confused:
or even better, just backup whole scripts dir and folders inside,
into ioFTPD\scripts\

Next step and most wanted would be to backup whole C:\ioFTPD\*.* and C:\Windrop\*.*
Is this possible?

Many thanks - max

Mr_X
10-07-2005, 11:54 AM
Yes, it's possible.
I think i'll redo it in C instead of batch (that has some limit).

It isn't necessary to backup whole ioftpd dir. The important things are config files.
Just make once a rar with ioftpd and eggdrop dir.
But i can add windrop conf and scripts to backup.

maX1mus
10-08-2005, 07:55 PM
Thanks for the answer. :)
Well how you do is up to you, thats out of my league ;)
Why i want to be able to backup whole ioFTPD and windrop is because after a while there has been a lot of changes to many scripts.
Could be rules welcome msg etc etc..
im thinking of running site backup scheduled maby once a week, and only most importent stuff, user groups and so on.
But maby do site backupall once a month or after a big update, or new scripts added.

thanks for sharing - max

Mr_X
11-02-2005, 06:48 PM
Updated.
Backup also scripts directory.
Now backup recursively directories.

Mr_X
11-03-2005, 06:43 AM
Just reupdated.
Was'nt copying recursively, fixed now.
If you downloaded 1.2, you can just change one line:
%EXEPATH%\robocopy.exe ..\scripts scripts >nul
by
%EXEPATH%\robocopy.exe ..\scripts scripts /e >nul

maX1mus
11-09-2005, 12:02 PM
Works really nice :)
I have a question tho,..
When it sends the zip is that made by ioFTPD.exe or ?
I need to allow something in the firewall at one place cause the backup from it gets only 0byte, and without firewall it works ;S

thx - _lefkas

Mr_X
11-09-2005, 02:09 PM
You need to allow ftp.exe from microsoft to access to Internet (and allowing it opening any port)
It can also be ioFTPD.exe but i'm not sure because you can connect to it (already allowed).
(I'm not in your firewall and i don't know the rules you use ;))

ChipMunk666
11-10-2005, 01:30 AM
I have another suggestion which would make me happy :)
And maybe a lot of other users...
I use sharedb.And i am fairly new to this...
But there is one error i have many times and that's ioShareDB: error register user
I fix this to copy the userfile from the "hub" to the "slave".
Is there a way to schedule this backup and send this to several slaves and servers but not in rar file?
This would help me a lot and probably a lot of others aswell

Mr_X
11-10-2005, 06:19 PM
I tried to schedule backup but it always fail and I don't know why because it worked fine with SITE command. I spent lots of time to search from where it comes without success.
I don't have so much time these days to investigate, i have nearly all days 8AM->6PM during the week + works for school.
I can restart working on it at the beginning of february when my exams will be done.

You wanted to schedule this.
I can make something to schedule but not with ioFTPD schedule (don't work very good as I said): my own that will stay in memory (and maybe one that will be installable as a service also).

I could also make another version that will be included in Service (all in one)

About copying userfile, I don't think it's possible to do while io is running because it locks these files. You have to stop ioFTPD and decompress user files.
Perhaps I'm wrong, but in this case, tell me.

maX1mus
11-10-2005, 06:46 PM
About copying userfile, I don't think it's possible to do while io is running because it locks these files. You have to stop ioFTPD and decompress user files.
Perhaps I'm wrong, but in this case, tell me.
Isnt that what the script does today? copy userfiles ..

Mr_X
11-10-2005, 07:56 PM
Sorry, forgot to mention that i was speaking (the things you quoted) about fixing problem with ioShareDB (overwritings files in slaves)

ChipMunk666
11-10-2005, 08:51 PM
I tried to schedule backup but it always fail and I don't know why because it worked fine with SITE command. I spent lots of time to search from where it comes without success.
I don't have so much time these days to investigate, i have nearly all days 8AM->6PM during the week + works for school.
I can restart working on it at the beginning of february when my exams will be done.

You wanted to schedule this.
I can make something to schedule but not with ioFTPD schedule (don't work very good as I said): my own that will stay in memory (and maybe one that will be installable as a service also).

I could also make another version that will be included in Service (all in one)

About copying userfile, I don't think it's possible to do while io is running because it locks these files. You have to stop ioFTPD and decompress user files.
Perhaps I'm wrong, but in this case, tell me.

i can copy it and replace it with no problem.It's ioshared remember :)
I can do this without stopping the servers.Eventually i do a restart anyway just to make sure it works :)
Would only be cool if a script or programm does for onece a day or so :)
No that it is so often that i get this error but better to make sure :)

PSA9
01-11-2013, 12:54 AM
could someone please post a link to v1.2.1 or tell me where i can download this! Thanks in advanced