LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 08-10-2017, 04:22 PM   #1
brodo
Member
 
Registered: Jan 2004
Location: Poland, Poznan
Distribution: Slackware current 32 / 64
Posts: 406

Rep: Reputation: 30
How to backup nicely a part of HDD's data dirs into a pendrive ?


I always used the following commands for creating protected archives:

tar cfz - foo/ | gpg -c -o output.tar.gz.gpg

When in need I use this for extracting:

gpg -d output.gpg | tar xfz -


Now I'd like to merge the following multipart archiving procedure into the above:

tar cvzf - /home/user/foo/ | split --bytes=2000MB - foo.tar.gz.


How can it be done ?
I'm not an expert in advanced bash, unfortunately ...
 
Old 08-10-2017, 08:43 PM   #2
Diantre
Member
 
Registered: Jun 2011
Distribution: Slackware
Posts: 515

Rep: Reputation: 234Reputation: 234Reputation: 234
To create the files, something like this works:

Code:
tar czf - foo/ | split --bytes=2MB --filter='gpg -c -o $FILE.gpg' - foo.tar.gz
But I'm having trouble coming up with a one-liner to join the split files, decrypt them and decompress them. Might be better to use a small script for that:

Code:
#!/bin/bash

for i in *.gpg; do gpg -d -o "${i%.gpg}" "$i"; done
cat *.gz?? | tar xzf -
Or maybe you can create the tarball, encrypt it, and then split it. Or maybe someone else can come up with a better idea...
 
Old 08-11-2017, 03:52 AM   #3
brodo
Member
 
Registered: Jan 2004
Location: Poland, Poznan
Distribution: Slackware current 32 / 64
Posts: 406

Original Poster
Rep: Reputation: 30
I tried creating archives, but it asks for a passphrase each time a partial file is to be processed, so it is not very usefull :-(
 
Old 08-11-2017, 07:43 AM   #4
IsaacKuo
Senior Member
 
Registered: Apr 2004
Location: Baton Rouge, Louisiana, USA
Distribution: Debian Stable
Posts: 2,546
Blog Entries: 8

Rep: Reputation: 465Reputation: 465Reputation: 465Reputation: 465Reputation: 465
Yeah, it would make more sense to create the full size encrypted archive first and then split it. Does gpg have an option to output to stdout rather than an output file? If so, then maybe this will work (I'm just guessing right now)...

Code:
tar cfz - foo/ | gpg -c | split --bytes=2000MB - foo.tar.gz.gpg.part
cat foo.tar.gz.gpg.part* | gpg -d | tar xfz -
If this works as I guess, then the first line will:

1) tar foo
2) encrypt the output of tar foo
3) split the output of encrypt the output of tar foo

and the second line will:

1) merge foo.tar.gz.gpg.part*
2) decrypt the merge of foo.tar.gz.gpg.part*
3) untar the decrypted merge of foo.tar.gz.gpg.part*

I think?
 
2 members found this post helpful.
Old 08-11-2017, 01:40 PM   #5
Diantre
Member
 
Registered: Jun 2011
Distribution: Slackware
Posts: 515

Rep: Reputation: 234Reputation: 234Reputation: 234
Quote:
Originally Posted by IsaacKuo View Post
Yeah, it would make more sense to create the full size encrypted archive first and then split it. Does gpg have an option to output to stdout rather than an output file? If so, then maybe this will work (I'm just guessing right now)...

Code:
tar cfz - foo/ | gpg -c | split --bytes=2000MB - foo.tar.gz.gpg.part
cat foo.tar.gz.gpg.part* | gpg -d | tar xfz -
Works just fine for me. Indeed, it's better to split after the encryption. Thanks!
 
Old 08-11-2017, 03:07 PM   #6
brodo
Member
 
Registered: Jan 2004
Location: Poland, Poznan
Distribution: Slackware current 32 / 64
Posts: 406

Original Poster
Rep: Reputation: 30
For me works well too, more testing now in progress !
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
how to rsync some dirs for backup? shams Linux - Software 1 01-01-2013 10:41 AM
How do I copy specific files and dirs from partition A to B in the same Hdd in Linux? AnApproach2DigestLinux Linux - Newbie 5 11-20-2012 06:05 PM
How to backup a user-space data from a dead computer (HDD functional) rebooted Linux - Newbie 8 04-04-2012 12:16 PM
[SOLVED] Apple gcc: Insert include dirs between -I dirs and -isysroot dirs f.barker Programming 1 11-11-2011 10:19 AM
Dual HDD Interface Problem, Linux on SATA, NTFS Part on IDE HDD LILO Not Loading Blade44 Linux - Hardware 2 02-01-2005 06:56 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 07:29 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration