Nieuws:

Welkom, Gast. Alsjeblieft inloggen of registreren.
Heb je de activerings-mail niet ontvangen?

Auteur Topic: [opgelost] Kopieren met verificatie  (gelezen 2773 keer)

Offline MKe

  • Lid
[opgelost] Kopieren met verificatie
« Gepost op: 2013/05/03, 08:43:56 »
Hoi,

Ik moet regelmatig zeer grote bestanden kopiëren (100 GB is geen uitzondering). Met het cp commando willen de bestanden nog wel eens corrupt raken. Hoe voorkom je dit? Ik weet dat ik de checksum achteraf kan checken e.d. maar is er ook een kopieer commando die dit automatisch doet en ervoor zorgt dat het kopieer proces goed verloopt? Het moet wel commandline zijn, ik kan dit niet met grafische tools.
« Laatst bewerkt op: 2013/05/03, 16:16:07 door MKe »
Mijn blokkendoos blog: http://mke21.wordpress.com/

Offline markba

  • Lid
    • http://markbaaijens.nl/
Re: Kopieren met verificatie
« Reactie #1 Gepost op: 2013/05/03, 09:57:49 »
Je kunt rsync gebruiken, eventueel met de optie -c (checksum):

Citaat
-c, --checksum
This changes the way rsync checks if the files have been changed and are in need of a transfer. Without this option, rsync uses a lqquick checkrq that (by default) checks if each file's size and time of last modification match between the sender and receiver. This option changes this to compare a 128-bit checksum for each file that has a matching size. Generating the checksums means that both sides will expend a lot of disk I/O reading all the data in the files in the transfer (and this is prior to any reading that will be done to transfer changed files), so this can slow things down significantly.

The sending side generates its checksums while it is doing the file-system scan that builds the list of the available files. The receiver generates its checksums when it is scanning for changed files, and will checksum any file that has the same size as the corresponding sender's file: files with either a changed size or a changed checksum are selected for transfer.

Note that rsync always verifies that each transferred file was correctly reconstructed on the receiving side by checking a whole-file checksum that is generated as the file is transferred, but that automatic after-the-transfer verification has nothing to do with this option's before-the-transfer lqDoes this file need to be updated?rq check.

Offline MKe

  • Lid
Re: Kopieren met verificatie
« Reactie #2 Gepost op: 2013/05/03, 14:13:01 »
Je kunt rsync gebruiken, eventueel met de optie -c (checksum):

Citaat
-c, --checksum
This changes the way rsync checks if the files have been changed and are in need of a transfer. Without this option, rsync uses a lqquick checkrq that (by default) checks if each file's size and time of last modification match between the sender and receiver. This option changes this to compare a 128-bit checksum for each file that has a matching size. Generating the checksums means that both sides will expend a lot of disk I/O reading all the data in the files in the transfer (and this is prior to any reading that will be done to transfer changed files), so this can slow things down significantly.

The sending side generates its checksums while it is doing the file-system scan that builds the list of the available files. The receiver generates its checksums when it is scanning for changed files, and will checksum any file that has the same size as the corresponding sender's file: files with either a changed size or a changed checksum are selected for transfer.

Note that rsync always verifies that each transferred file was correctly reconstructed on the receiving side by checking a whole-file checksum that is generated as the file is transferred, but that automatic after-the-transfer verification has nothing to do with this option's before-the-transfer lqDoes this file need to be updated?rq check.
Bedankt! Als ik het goed lees is de optie -c niet nodig?:
Citaat
Note that rsync always verifies that each transferred file was correctly reconstructed on the receiving side by checking a whole-file checksum that is generated as the file is transferred

Offline markba

  • Lid
    • http://markbaaijens.nl/
Re: Kopieren met verificatie
« Reactie #3 Gepost op: 2013/05/03, 14:37:10 »
Klopt, de checksum-optie bepaalt alleen een preciezere bepaling welke bestanden gesynchroniseerd worden en gaat niet over het het hoe: de overdrachtscontrole op checksum vindt idd automatisch plaats. Daarom had ik er al 'eventueel'  bij gezet .

Offline MKe

  • Lid
Re: Kopieren met verificatie
« Reactie #4 Gepost op: 2013/05/03, 16:15:28 »
Okay, heel erg bedankt voor de uitleg, het lijkt tot nu toe prima te werken.

Offline jan11000

  • Lid
Re: [opgelost] Kopieren met verificatie
« Reactie #5 Gepost op: 2013/05/03, 20:17:44 »
Netwerk kontroleren doe ik door 49 GB aan files die gepard zijn(par2), dan kun je ze aan de andere kant kontroleren.
Na de kopieer actie, start de terminal, met ifconfig kun je zien of er fouten optreden.
Welke protocol gebruik je?
In de samba config file, kun je met de volgende waarden spelen, dus groter of kleiner maken,
# Most people will find that this option gives better performance.
# See smb.conf(5) and /usr/share/doc/samba-doc/htmldocs/Samba3-HOWTO/speed.html
# for details
# You may want to add the following on a Linux system:
#         SO_RCVBUF=8192 SO_SNDBUF=8192
#   socket options = TCP_NODELAY
   socket options = TCP_NODELAY SO_RCVBUF=65536 SO_SNDBUF=65536
Google hier maar op.

Voor nfs kun je ook verschillende instellingen proberen.

Dus wijzigingen toepassen en testen met de par2 files.

Offline vanadium

  • Lid
Re: [opgelost] Kopieren met verificatie
« Reactie #6 Gepost op: 2013/05/04, 09:58:45 »
Zoals gezegd, haalt de -c option hier niet zoveel uit. Je krijgt een garantie dat niet overgekopieerde bestanden identiek zijn, maar je krijgt geen garantie dat wel overgekopieerde bestanden identiek zijn (los dan van de standaard foutcontrole die je hebt met cp of rsync).

Ik denk dat de enige volledig betrouwbare manier een vergelijking is nadat het kopiëren is afgelopen, en alle geheugenbuffers geflushed zijn. Dat kan dan met cmp gebeuren, of met md5sum.

Offline vanadium

  • Lid
Re: [opgelost] Kopieren met verificatie
« Reactie #7 Gepost op: 2013/05/04, 10:14:31 »
Volgende wijze blijkt te werken om automatisch een ganse folder te hashen en te checken:

Aanmaken van mdf checksums:

find Archief/ -exec md5sum -b "{}" \; >md5sum.txt
Om te controleren:
md5sum -c md5sum.txt

Offline markba

  • Lid
    • http://markbaaijens.nl/
Re: [opgelost] Kopieren met verificatie
« Reactie #8 Gepost op: 2013/05/04, 10:18:58 »
Zoals gezegd, haalt de -c option hier niet zoveel uit. Je krijgt een garantie dat niet overgekopieerde bestanden identiek zijn, maar je krijgt geen garantie dat wel overgekopieerde bestanden identiek zijn (los dan van de standaard foutcontrole die je hebt met cp of rsync).
Volgens de documnetatie van rsync:

Citaat
Note that rsync always verifies that each transferred file was correctly reconstructed on the receiving side by checking a whole-file checksum that is generated as the file is transferred

Offline vanadium

  • Lid
Re: [opgelost] Kopieren met verificatie
« Reactie #9 Gepost op: 2013/05/05, 12:59:19 »
Zoals gezegd, haalt de -c option hier niet zoveel uit. Je krijgt een garantie dat niet overgekopieerde bestanden identiek zijn, maar je krijgt geen garantie dat wel overgekopieerde bestanden identiek zijn (los dan van de standaard foutcontrole die je hebt met cp of rsync).
Volgens de documnetatie van rsync:

Citaat
Note that rsync always verifies that each transferred file was correctly reconstructed on the receiving side by checking a whole-file checksum that is generated as the file is transferred

En dus maakt, zoals gezegd, die -c optie hier niets uit.

Offline MKe

  • Lid
Re: [opgelost] Kopieren met verificatie
« Reactie #10 Gepost op: 2013/05/06, 08:35:43 »
Hoi,

Bedankt voor alle antwoorden. Ik heb dus de optie om een script te schrijven die automatisch de checksums controleert van bron en target bestand na het kopiëren. Als het vervolgens niet klopt zou het script de kopieeractie opnieuw moeten uitvoeren. Dit lijkt mij nogal inefficiënt, maar als het de enige goed manier is zal ik dit wel doen. Maar als jullie erover eens zijn dat rsync dit net zo goed doet in dit geval heb ik daar de voorkeur voor. Ik heb het nu een aantal keren gebruikt sinds vrijdag en tot nu toe geen corrupte files meer gehad.