- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- backup & restore user home directory include hidde...
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-01-2011 06:24 PM
тАО03-01-2011 06:24 PM
I'm looking for simple bash scripts running from the desktop:
1.) backup the user home directory include all hidden files:
tar cvzf /save/user.tar.gz /home/user
2.) restore from the backup /save/user.tar.gz
cd /home/user
tar xvzf /save/user.tar.gz; cd -
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-01-2011 09:50 PM
тАО03-01-2011 09:50 PM
Solution> [...] running from the desktop:
Define "the desktop".
> tar c[...] /home/user
You may save yourself some work later if you
avoid specifying an absolute path when you
create your archive. For example:
cd /home
tar c[...] user
cd /home
tar x[...]
GNU "tar" has enough options to let you
recover from many kinds of unwise usage, but
why make more work for yourself than you need
to?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-02-2011 05:14 PM
тАО03-02-2011 05:14 PM
Re: backup & restore user home directory include hidden files
1.) Backup script:
#! /bin/bash
echo 'Backup user home dir'
cd /home
tar cvzf /home/user/save/backup.tar.bz2 $HOME
2.) Restore script:
#! /bin/bash
echo 'Restore user home dir'
cd /home
tar xvzf /home/user/save/backup.tar.bz2
Backup seems to work well, but if I try to restore I get this problem:
# sh restore
Restore user home dir
tar (child): /home/user/save/backup.tar.bz2: Cannot open: No such file or directory
tar (child): Error is not recoverable: exiting now
tar: Child returned status 2
tar: Error is not recoverable: exiting now
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-02-2011 05:33 PM
тАО03-02-2011 05:33 PM
Re: backup & restore user home directory include hidden files
I normally write for old "tar" programs, so I
normally make my own compression pipelines,
so I know nothing, but doesn't "-z" imply the
use of gzip, not bzip2? I don't know what
all these programs will do is you give them
inappropriate file-name suffixes.
http://www.gnu.org/software/tar/manual/
As I read it, "-a" ("--auto-compress") might
be more flexible.
> Backup seems to work well, [...]
Evidence?
What's in "/home/user/save/"? With my weak
psychic powers, I can't see it from here.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-03-2011 05:42 AM
тАО03-03-2011 05:42 AM
Re: backup & restore user home directory include hidden files
I think it would be a better idea to save the backup outside of the home dir (which is also the subject of the backup) By this you would avoid backing up the already-created backups. What do you think?
Regards,
Viktor
Unix operates with beer.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-03-2011 05:43 AM
тАО03-03-2011 05:43 AM
Re: backup & restore user home directory include hidden files
tar cvzf /home/user/save/backup.tar.bz2 $HOME
Unix operates with beer.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-03-2011 05:09 PM
тАО03-03-2011 05:09 PM
Re: backup & restore user home directory include hidden files
I've setup permissons in /save directory for a normal non-root user.
I changed to tar.gz and it should backup outside of the home dir:
backup:
tar cvzf /save/backup.tar.gz $HOME
restore:
tar xvzf /save/backup.tar.gz
Now, if I try to restore using:
tar xvzf /save/backup.tar.gz
then the extra /home/user/home/user will be created, instead of extracting directly into /home/user/*.
Howto solve this problem?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-03-2011 05:22 PM
тАО03-03-2011 05:22 PM
Re: backup & restore user home directory include hidden files
Should we non-psychics know what "$HOME" is
in this situation?
> Now, if I try to restore using:
Starting where, exactly?
pwd
> Howto solve this problem?
Read previous replies? Read the "tar"
documentation?
Also potentially useful:
man basename
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-03-2011 06:21 PM
тАО03-03-2011 06:21 PM
Re: backup & restore user home directory include hidden files
$HOME is home directory, it's dynamic.
It does the same like:
tar cvzf /save/backup.tar.gz /home/user
on my debian squeeze.
I try to restore, inside from /home/user, because I'd like to do it as a normal non-root user.
I think, running from / as a root user shouldn't be a problem.
Perhaps I'll try completely other solution:
copy ALL from /home/user/* into /save/*
and runnig this script outside of home dir:
#! /bin/bash
echo 'restore user settings'
cd /save
find . -print | cpio -dumpv /home/user
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-03-2011 07:42 PM
тАО03-03-2011 07:42 PM
Re: backup & restore user home directory include hidden files
Thanks for the explanation, but I think that
I understood that much. However, you demand
that I assume/guess that its value is
"/home/user/" in things like:
> then the extra /home/user/home/user will be
> created [...]
You're the one who wants help. I think that
you should be clear about what you want and
what you're doing. It's not my job to guess
what you really mean.
> Mar 2, 2011 05:50:04 GMT 10 pts
> [...]
> cd /home
> tar c[...] user
>
> cd /home
> tar x[...]
> [...]
What, exactly, was wrong with that plan? Did
you try it (or anything like it)?
> man basename
echo basename "$HOME"
Just a thought.
You might also consider something like:
cd /home/user
tar c[...] .
cd /home/user
tar x[...]
Perhaps:
cd "$HOME"
or:
cd
In general, "tar" stores paths in the archive
which look like the paths you specify when
you create the archive. Then, when you
extract the files from an archive, it tries
to reproduce those stored paths. If you
don't want to see "/home/user" when you
restore the stuff, then don't say
"/home/user" to "tar" when you create the
archive. Often informative:
tar t[...]
> http://www.gnu.org/software/tar/manual/
Seriously, you _really_ should look at the
documentation. GNU "tar" provides many
options which let you play with the paths
when you create an archive, and when you
extract the files from it. Even if you
insist on creating the archive using
(inappropriate, unhelpful) absolute paths,
GNU "tar" allows you to extract the files to
pretty much any location you might choose.
But wise use of "cd" and appropriate,
relative path specifications can make these
things pretty easy in many cases, even
without using any fancy GNU-"tar"-specific
command options.