| View previous topic :: View next topic |
| Author |
Message |
FastTurtle Guru


Joined: 03 Sep 2002 Posts: 369 Location: Shake & Bake
|
Posted: Tue Apr 09, 2013 3:25 pm Post subject: Help with creating Tarball System backups |
|
|
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 |
|
 |
John R. Graham Administrator


Joined: 08 Mar 2005 Posts: 6443 Location: Somewhere over Atlanta, Georgia
|
Posted: Tue Apr 09, 2013 3:28 pm Post subject: |
|
|
Use | Code: | | tar -cpvzf /storage/backups/usr.tar.gz usr | instead. Order of command line elements wrong is all.
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 |
|
 |
krinn Advocate


Joined: 02 May 2003 Posts: 3677
|
Posted: Tue Apr 09, 2013 4:45 pm Post subject: |
|
|
| how about stage4 script that does all the work for you ? |
|
| Back to top |
|
 |
FastTurtle Guru


Joined: 03 Sep 2002 Posts: 369 Location: Shake & Bake
|
Posted: Tue Apr 09, 2013 7:42 pm Post subject: |
|
|
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 |
|
 |
John R. Graham Administrator


Joined: 08 Mar 2005 Posts: 6443 Location: Somewhere over Atlanta, Georgia
|
Posted: Tue Apr 09, 2013 8:22 pm Post subject: |
|
|
| FastTurtle wrote: | Should it read | Code: | | tar -cpzvf usr /storage/backups/usr.tar.gz |
| No, you got it backwards again. I posted the correct command line in my original reply.
- John _________________ This space intentionally left blank. |
|
| Back to top |
|
 |
FastTurtle Guru


Joined: 03 Sep 2002 Posts: 369 Location: Shake & Bake
|
Posted: Tue Apr 09, 2013 8:42 pm Post subject: |
|
|
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 |
|
 |
John R. Graham Administrator


Joined: 08 Mar 2005 Posts: 6443 Location: Somewhere over Atlanta, Georgia
|
Posted: Tue Apr 09, 2013 8:47 pm Post subject: |
|
|
Yes, correct.
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 |
|
 |
John R. Graham Administrator


Joined: 08 Mar 2005 Posts: 6443 Location: Somewhere over Atlanta, Georgia
|
Posted: Wed Apr 10, 2013 7:39 pm Post subject: |
|
|
| 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 |
|
 |
wcg Guru

Joined: 06 Jan 2009 Posts: 556
|
Posted: Wed Apr 10, 2013 11:55 pm Post subject: |
|
|
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 |
|
 |
FastTurtle Guru


Joined: 03 Sep 2002 Posts: 369 Location: Shake & Bake
|
Posted: Fri Apr 12, 2013 1:42 am Post subject: |
|
|
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
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 |
|
 |
Jimmy Jazz Apprentice


Joined: 04 Oct 2004 Posts: 271 Location: Strasbourg
|
Posted: Fri Apr 12, 2013 3:22 pm Post subject: |
|
|
| FastTurtle wrote: | John:
I'm thinking
|
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 |
|
 |
|