Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Help with creating Tarball System backups
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Portage & Programming
View previous topic :: View next topic  
Author Message
FastTurtle
Guru
Guru


Joined: 03 Sep 2002
Posts: 369
Location: Shake & Bake

PostPosted: Tue Apr 09, 2013 3:25 pm    Post subject: Help with creating Tarball System backups Reply with quote

Need to confirm I've got the command right to create a tarball of an entire directory

Code:
tar -cpvzf usr /storage/backups/usr.tar.gz


should create a compressed tarball of the /usr directory while maintaining the permissions like the stage3 tarballs we use during installation.

If I've got something wrong, shout out as I don't want to screw this up.
Back to top
View user's profile Send private message
John R. Graham
Administrator
Administrator


Joined: 08 Mar 2005
Posts: 6443
Location: Somewhere over Atlanta, Georgia

PostPosted: Tue Apr 09, 2013 3:28 pm    Post subject: Reply with quote

Use
Code:
tar -cpvzf /storage/backups/usr.tar.gz usr
instead. Order of command line elements wrong is all. :wink:

You might also want to consider using an absolute path for the usr directory so your command isn't dependent on the current directory.

- John
_________________
This space intentionally left blank.
Back to top
View user's profile Send private message
krinn
Advocate
Advocate


Joined: 02 May 2003
Posts: 3677

PostPosted: Tue Apr 09, 2013 4:45 pm    Post subject: Reply with quote

how about stage4 script that does all the work for you ?
Back to top
View user's profile Send private message
FastTurtle
Guru
Guru


Joined: 03 Sep 2002
Posts: 369
Location: Shake & Bake

PostPosted: Tue Apr 09, 2013 7:42 pm    Post subject: Reply with quote

Thanks for catching that Graham:

Should it read
Code:
tar -cpzvf usr /storage/backups/usr.tar.gz


krinn: The main problem with using a stage4 script is I don't understand what all the script is doing. So I'm going for the solution that does what I need for the time being and once I have time to dig into the scripts, I may use it as the base for what I intend on doing in the future.
Back to top
View user's profile Send private message
John R. Graham
Administrator
Administrator


Joined: 08 Mar 2005
Posts: 6443
Location: Somewhere over Atlanta, Georgia

PostPosted: Tue Apr 09, 2013 8:22 pm    Post subject: Reply with quote

FastTurtle wrote:
Should it read
Code:
tar -cpzvf usr /storage/backups/usr.tar.gz
No, you got it backwards again. :P I posted the correct command line in my original reply.

- John
_________________
This space intentionally left blank.
Back to top
View user's profile Send private message
FastTurtle
Guru
Guru


Joined: 03 Sep 2002
Posts: 369
Location: Shake & Bake

PostPosted: Tue Apr 09, 2013 8:42 pm    Post subject: Reply with quote

Thanks Graham for the clu-x-4 as I'd thought that was part of a quote.

Now I've got it, the filename to be created follows after the command with the directory that's the base for the tarball is last.

Almost correct - needed the /usr for it to create the tarball of the /usr directory. Should have enough space on the drive for the backup.

Now it's just a matter of figuring out how to get it to do a compare before hand (scripting is going to be good) as I want to setup a cron job to backup user data but only if changes have occured.


Last edited by FastTurtle on Tue Apr 09, 2013 8:54 pm; edited 1 time in total
Back to top
View user's profile Send private message
John R. Graham
Administrator
Administrator


Joined: 08 Mar 2005
Posts: 6443
Location: Somewhere over Atlanta, Georgia

PostPosted: Tue Apr 09, 2013 8:47 pm    Post subject: Reply with quote

Yes, correct. :D

Just as an aside, you can specify multiple files or directories in place of the single usr. Cheers.

- John
_________________
This space intentionally left blank.
Back to top
View user's profile Send private message
John R. Graham
Administrator
Administrator


Joined: 08 Mar 2005
Posts: 6443
Location: Somewhere over Atlanta, Georgia

PostPosted: Wed Apr 10, 2013 7:39 pm    Post subject: Reply with quote

FastTurtle wrote:
...
Now it's just a matter of figuring out how to get it to do a compare before hand (scripting is going to be good) as I want to setup a cron job to backup user data but only if changes have occured.
There is a name for your eventually completed script: a backup program. ;)

There's a whole category in the Portage tree dedicated to the wheel you're trying to reinvent...er, problem you're trying to solve: app-backup. My suggestion would be to try out some of those until you find something you like. A forum search of the term "backup" will also provide some interesting reading.

Also, it's worth noting that there's very little user data in /usr, ironically enough. Most of it is in /home and /root.

- John
_________________
This space intentionally left blank.
Back to top
View user's profile Send private message
wcg
Guru
Guru


Joined: 06 Jan 2009
Posts: 556

PostPosted: Wed Apr 10, 2013 11:55 pm    Post subject: Reply with quote

Code:

-cpvzf


These are your command line options for the tar command. The filename
of the tar file that you want to create is a parameter to the "-f" command
line option.

Think of it this way:
Code:

tar -f /storage/backups/usr.tar.gz -c -p -v -z /usr


(That command does the same thing, but you can see that the output
pathname is part of the "-f" option to tar.)
_________________
TIA
Back to top
View user's profile Send private message
FastTurtle
Guru
Guru


Joined: 03 Sep 2002
Posts: 369
Location: Shake & Bake

PostPosted: Fri Apr 12, 2013 1:42 am    Post subject: Reply with quote

John:

I'm not trying to reinvent the wheel. I ran out of space on /usr (seperate partitions) so I have to use this method to back things up before I purge the partitions after /. With my repartitioning (/usr and /var both go to 24GB while /var/tmp goes to 16GB) and I'm moving /home to a new 2TB Drive (consolidates /home from 2 drives). Once done, I'll have about 400GB of free space to figure out what to do with.

Once I'm back up and running, I'll check out the various backup packages to see which one strikes me as filling my needs though I do like the idea of developing my own script/cron job to deal with what I consider important backups.

WCG:

I've already tested the command structure along with getting into both the man and info page for tar. Yes the structure is pretty straight forward though the one thing I've not found is a decent example of how to exclude a directory.

I'm thinking
Code:
--exclude /var/tmp

is what's needed but not sure. If I'm correct, then I can simply create a single tarball of /usr, /usr/portage and /var (minus the damn temp files) and restore with a single command once the partitions are mounted.
Back to top
View user's profile Send private message
Jimmy Jazz
Apprentice
Apprentice


Joined: 04 Oct 2004
Posts: 271
Location: Strasbourg

PostPosted: Fri Apr 12, 2013 3:22 pm    Post subject: Reply with quote

FastTurtle wrote:
John:

I'm thinking
Code:
--exclude /var/tmp



more selectively
Code:

tar cjpf /where/to.tar.xz --exclude-from fileto.excl  -C /var local -C /var lib -C /var tmp

with
Code:
cat fileto.excl
tmp/portage
or
tmp/portage/*

both relative to /var :)
_________________
« La seule condition au triomphe du mal, c'est l'inaction des gens de bien » E.Burke
Code:

+----+----+----+
|    |::::|    |
|    |::::|    |
+----+----+----+

motto: WeLCRO
WritE Less Code, Repeat Often
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Portage & Programming All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum