sl33pwalker
Goto Top

Datei von URL mit Benutzername- und Passwort-Abfrage automatisiert abspeichern

Hallo zusammen,

folgende Ausgangssituation:

Es wird jede Nacht um 3 Uhr ein dump erzeugt, welcher per HTTP heruntergeladen werden soll. Beispiel-URL: http://example.development.com/dumps/latest.dump
Das Ganze ist mit Benutzernamen und Passwort geschützt.

Diesen dump würde ich gerne einmal täglich automatisiert herunterladen und auf einem Netzlaufwerk abspeichern.
Des Weiteren soll immer ein aktueller Dump und der des Vortages verfügbar sein, alles andere am besten automatisiert gelöscht.

Hat jemand eine Idee, wie man das am besten realisieren kann?

Besten Dank & Gruß,
Nils

Content-Key: 176564

Url: https://administrator.de/contentid/176564

Printed on: April 16, 2024 at 19:04 o'clock

Member: thaenhusen
thaenhusen Nov 21, 2011 at 10:11:30 (UTC)
Goto Top
Moin.

Wenn Du ein Linux-System verfügbar hast geht das mit wget.

HTH
MK
Member: sl33pwalker
sl33pwalker Nov 21, 2011 at 10:15:46 (UTC)
Goto Top
Bin unter Windows unterwegs ;)
Member: thaenhusen
thaenhusen Nov 21, 2011 at 10:19:22 (UTC)
Goto Top
Moin.

Dann gehts vieleicht damit http://gnuwin32.sourceforge.net/packages/wget.htm ?
Habe ich aber noch nie probiert...

HTH
MK
Mitglied: 60730
60730 Nov 21, 2011 at 13:01:15 (UTC)
Goto Top
moin,

wie geschrieben wget
und am ende kommt ein move datei.suffix archiv.suffix dazu, dann hast du zur aktuellen noch genau eine alte Version.

Gruß
Member: sl33pwalker
sl33pwalker Nov 21, 2011 at 13:55:36 (UTC)
Goto Top
Servus,

hatte es mit wget auch schon mal probiert, aber nicht so wirklich hinbekommen.
Habe mir das Ganze jetzt nochmal in Ruhe durchgelesen und zusammen mit der Taskplanung von Windows täglich duchkonfiguriert - läuft.

Besten Dank an euch beide.

Gruß
Member: sl33pwalker
sl33pwalker Nov 22, 2011 at 10:38:57 (UTC)
Goto Top
Das klappt mit wget und der Taskplanung eigentlich ganz gut, allerdings habe ich noch ein Problem.
Die Datei die runtergeladen wird, soll überschrieben werden, aber entweder sagt mir die Konsole die Datei ist schon vorhanden (noclobber = on) oder sie wird mit .1 zusätzlich (noclobber = off) zur existierenden Datei geschrieben.

Welcher Befehl sorgt dafür, dass die Datei einfach überschrieben wird?
Member: thaenhusen
thaenhusen Nov 22, 2011 at 11:20:03 (UTC)
Goto Top
Moin.

"...
-nc
--no-clobber
If a file is downloaded more than once in the same directory, Wget's behavior depends on a few options,
including -nc. In certain cases, the local file will be clobbered, or overwritten, upon repeated download.
In other cases it will be preserved.

When running Wget without -N, -nc, or -r, downloading the same file in the same directory will result in the
original copy of file being preserved and the second copy being named file.1. If that file is downloaded
yet again, the third copy will be named file.2, and so on. When -nc is specified, this behavior is sup-
pressed, and Wget will refuse to download newer copies of file. Therefore, ``"no-clobber"'' is actually a
misnomer in this mode---it's not clobbering that's prevented (as the numeric suffixes were already
preventing clobbering), but rather the multiple version saving that's prevented.

When running Wget with -r, but without -N or -nc, re-downloading a file will result in the new copy simply
overwriting the old. Adding -nc will prevent this behavior, instead causing the original version to be pre-
served and any newer copies on the server to be ignored.

When running Wget with -N, with or without -r, the decision as to whether or not to download a newer copy of
a file depends on the local and remote timestamp and size of the file. -nc may not be specified at the same
time as -N."

Also sollte wget -r http://www.wasweissich.de/datei.name helfen. Ohne -N oder -nc.

HTH
MK
Member: sl33pwalker
sl33pwalker Nov 22, 2011 at 11:29:59 (UTC)
Goto Top
Servus,

das hatte ich auch schon gefunden, weiß aber noch nicht so wirklich wo ich das einsetzten soll,
vielleicht hilft ein kurzer Auszug aus meiner Batch:

@echo off
rem **************************************************************************
rem * Test_Batch_Dump
rem **************************************************************************
rem  
if !%1! == !2nd! goto 2nd
%COMSPEC% /e:2000 /c "%0" 2nd  
exit
:2nd
set WGETRC=C:\DOKUME~1\ADMINI~1.BOD\LOKALE~1\Temp\2\280503771.wgetrc
if exist %WGETRC% del %WGETRC%
echo recursive = off >>%WGETRC%
echo no_parent = off >>%WGETRC%
echo force_html = off >>%WGETRC%
echo html_extension = off >>%WGETRC%
echo convert_links = off >>%WGETRC%
echo dirstruct = off >>%WGETRC%
echo page_requisites = off >>%WGETRC%
echo passive_ftp = off >>%WGETRC%
echo continue = off >>%WGETRC%
echo timestamping = off >>%WGETRC%
echo robots = on >>%WGETRC%
echo http_user = user@account.com >>%WGETRC%
echo http_passwd = xxxxxx >>%WGETRC%

X:
cd \
if not exist XXX\nul md XXX
cd XXX
if not exist "XXX Dump\nul" md "XXX  Dump"  
cd "XXX  Dump"  
if not exist Sicherung\nul md Sicherung
cd Sicherung
C:\WINDOWS\system32\wget http://wasweissichcom/dumps/latest.dump
echo _______________________________________________________________________________
echo.
pause


In der viertletzten Zeile nach wget ein "-r" reinzuschreiben habe ich schon probiert, das klappt nicht :/
Mitglied: 60730
60730 Nov 22, 2011 at 11:48:47 (UTC)
Goto Top
moin,

ganz hybsch, aber schau dir mal Zeile 23 genauer an..Ich sag nur die iluminaten waren es diesmal nicht...

dann sowas, wie
echo recursive = off >>%WGETRC%
ist unhybsch...und Leerzeichen sollten einem immer eine Lehre sein...
echo recursive = off>>%WGETRC%

Dann kommt es auch immer drauf an, welche Version vom WinWget du da nimmst...
Und abschliessend - warum soviele Zeilen, wenn das Passwort eh in der Batch steht, mußt du doch keine WGETRC bauen, wo das dann nochmal drin steht...

call wget.exe -N --no-cache http_user = user@domain.de http_passwd = xxxxxx http://wasweissichcom/dumps/latest.dump

Gruß
Member: sl33pwalker
sl33pwalker Nov 24, 2011 at 10:55:07 (UTC)
Goto Top
So, besten Dank nochmal.

Läuft jetzt mit:

C:\WINDOWS\system32\wget.exe "http://wasweissichcom/dumps/latest.dump" -P "" -r --http-user=user@domain.de" --http-pass="xxxXXXxxx"  

und überschreiben tut er die Datei ebenfalls.

Gruß