Sometimes when you want to store your backup or any other large set of files online or want to share them someone else you need to find a way to compress and split the files into chunks of 100 or more Megabytes. Dažreiz, ja vēlaties saglabāt savu rezerves vai citu daudzas failu tiešsaistē vai vēlaties dalīties ar viņiem kāds cits jums nepieciešams atrast veidu, lai saspiestu un sadalīt failus gabali ir 100 vai vairāk megabaiti. I felt the need for this as well recently when I wanted to store my backups online and the online storage service had a cap of 100 MB per file. Es jutu vajadzību, lai tas, tāpat kā nesen, kad es gribēju saglabāt mans backups tiešsaistē un tiešsaistes uzglabāšanas pakalpojums tika vāciņu ar 100 MB per file. I found a really neat solution based on the tar command. Es atklāju tiešām veikls risinājums, kas balstīts uz tar komandu. Using this method I split my backup of about 1 GB into 10 chunks of 100 MB each with incremental filenames. Izmantojot šo metodi es sadalīts mans backup aptuveni 1 GB stājās 10 gabalus 100 MB katra ar papildu failu nosaukumi.
The 1 GB file I wanted to split was called dbbackup.db . 1 GB failu gribēju sadalīt sauca dbbackup.db. Here's the command I ran to create multiple tar files of 100 MB each out of it: Šeit ir komanda I ilga, lai izveidotu vairākus tar failus 100 MB katra no tā:
# tar -cf – dbbackup.db | split -b 100m – db_backup.tar # Tar-cf - dbbackup.db | split-b 100m - db_backup.tar
This command took a long time to run. Šī komanda bija daudz laika, lai darbotos. Once it was done running I was left with ten files, 100 MB each named db_backup.taraa , db_backup.tarab , db_backup.tarac , and so on and so forth. Kad tas tika izdarīts rādīt man palika desmit failiem, 100 MB katra nosauktā db_backup.taraa, db_backup.tarab, db_backup.tarac, un tā tālāk un tā tālāk.
Now I can copy these files to my external storage or ship them with ease. Tagad es varētu pārkopēt failus uz manu ārējās glabāšanas vai nosūtīt tos ar vieglumu. To stitch the 1GB file back together all I need to do is to run the following command: Uz sašūtiem 1GB failu atpakaļ kopā visas man ir jādara, ir palaist šādu komandu:
# cat db_backup.tara* | (tar x) # Cat db_backup.tara * | (darvas x)
And voila, I get my original file again. Un voila, man manu sākotnējo failu vēlreiz.























{ 1 trackback } (1 Trackback)
{ 2 comments… read them below or (2 comments ... lasīt tos zem vai add one pievienot vienu } )
Perhaps I am missing something. Varbūt es esmu missing something. For a single large file why not simply use the split command by itself? Par vienu lielu failu kāpēc ne vienkārši izmanto split komanda pati par sevi? Executing a single command might be faster than executing both tar and split. Izpildot vienu komandu var būt ātrāks nekā izpildes gan darvu un sadalīts.
split –bytes=1024b sdbackup.db db_backup_ split-bytes = 1024b sdbackup.db db_backup_
cat db_backup_* > joined_file.db kaķis db_backup_ *> joined_file.db
Perhaps a better example would show the same operation used on multiple folders Varbūt labāk piemērs varētu parādīt pašas operācijas izmanto vairākas mapes
# tar -cf – /var/www /var/ftp | split -b 100m – my_backup.tar # Tar-cf - / var / www / var / ftp | split-b 100m - my_backup.tar
To guard against missing or damaged pieces, install “par2cmdline”, and create parity files so that you can repair missing pieces. Lai izsargātos no trūkstošās vai bojātās daļas, instalējiet "par2cmdline", un izveidot paritātes failus, lai varat remontam trūkstošos gabalus.
To create parity files with a 15% redundency: Lai izveidotu vienlīdzīgus failus ar 15% redundency:
# par2 create -r15 my_backup.tara* # Par2 create-r15 my_backup.tara *
To verify: Pārbaudītu:
# par2 verify my_backup.taraa.par2 # Par2 pārbaudīt my_backup.taraa.par2
To repair missing pieces: Remonta trūkst gabali:
# par2 repair my_backup.taraa.par2 # Par2 remonts my_backup.taraa.par2
To combine the pieces and extract: Apvienot gabaliņos un ekstrakts:
# cat my_backup.tara? # Cat my_backup.tara? | (tar x) | (Darvas x)
Leave a Comment Leave Comment