- 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
Forums
Discussions
Discussions
Discussions
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
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-03-2011 07:47 PM
03-03-2011 07:47 PM
Re: backup & restore user home directory include hidden files
And how do you propose to do that if you
still want to "include hidden files"?
If you figure out how to use "tar", then you
shouldn't need to do any of this "copy"
nonsense.
By the way, do you _really_ want to overwrite
_everything_ in this "/home/user" directory?
(Why?)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-04-2011 04:51 PM
03-04-2011 04:51 PM
Re: backup & restore user home directory include hidden files
still want to "include hidden files"?""
for example:
cp -a /home/user /save
should copy all files include hidden files into /save/user
""If you figure out how to use "tar", then you
shouldn't need to do any of this "copy""
nonsense.
Sorry, I need a quick solution and using tar didn't work as a normal non-root user to run inside a home dir.
Perhaps that was a mistake.
It should work as a tar x script to run it outside of the home dir.
Anyway if I have more time, I'll look at the tar documentation.
""By the way, do you _really_ want to overwrite
_everything_ in this "/home/user" directory?
(Why?)""
because i try to prepare a client and it should be possible to reset all user settings.
thx a lot and greetings
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-04-2011 08:32 PM
03-04-2011 08:32 PM
Re: backup & restore user home directory include hidden files
What, exactly, didn't work? The one thing
which you said you tried, or one of the other
things which I suggested?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-05-2011 04:21 AM
03-05-2011 04:21 AM
Re: backup & restore user home directory include hidden files
tar x exctract in the wrong path, it creates extra directory inside home dir.
I should find a solution to generate exact destination path using tar.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-05-2011 07:07 AM
03-05-2011 07:07 AM
Re: backup & restore user home directory include hidden files
>
> tar x exctract in the wrong path, [...]
WHEN YOU DID _WHAT_? Which part of "exactly"
was unclear? What "tar x" does depends on
what's in the archive, and my psychic powers
are too weak to tell me what you're doing.
As usual, showing actual commands with their
actual output can be more helpful than vague
descriptions or interpretations.
> You might also consider something like:
>
> cd /home/user
> tar c[...] .
> [...]
Do you ever read this stuff? Do you ever try
these things?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-05-2011 01:58 PM
03-05-2011 01:58 PM
Re: backup & restore user home directory include hidden files
as Stewen suggests, before making the tar archive cd to the home directory and issue the tar command with relative path. (that is, with a dot at the end). This way you store the data with relative path, and no additional dirs will be created. Note that you also need to cd to the home before untaring.
Unix operates with beer.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-05-2011 01:59 PM
03-05-2011 01:59 PM
Re: backup & restore user home directory include hidden files
Unix operates with beer.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-05-2011 05:08 PM
03-05-2011 05:08 PM
Re: backup & restore user home directory include hidden files
Running these scripts outside of home dir works really well:
backup:
#! /bin/bash
echo 'Backup user home dir'
cd /home
tar cvzf /save/user.tar.gz /home/user .
and resore:
#! /bin/bash
echo 'Restore user home dir'
cd /home
tar xvzf /save/user.tar.gz
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-05-2011 06:14 PM
03-05-2011 06:14 PM
Re: backup & restore user home directory include hidden files
> tar cvzf /save/user.tar.gz /home/user .
You seem to have missed the point about
specifying relative versus absolute paths to
"tar".
> [...] /home/user .
Why both "/home/user" _and_ "."? You might
try them one at a time, and see which one
does what you want. (If either of them
does.)
> cd /home
> tar xvzf /save/user.tar.gz
For a "tar" archive with absolute paths, does
that "cd" command actually do anything for
you?
What's actually in your archive?
tar tvzf /save/user.tar.gz
> [...] works really well:
If you think so, then you should probably
look again.
> [...] I need a quick solution [...]
Sometimes it's helpful to slow down and take
enough time to understand what you're doing,
rather that simply trying to throw guesses at
the problem until something works (or _seems_
to work). This really is simpler than you're
making it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-05-2011 07:49 PM
03-05-2011 07:49 PM
Re: backup & restore user home directory include hidden files
> [...] What's actually in your archive?
I have unpacked the archive using:
tar xzvf user.tar.gz
and it seems to have the same contents 1:1 like in /home/user
Before, I've tried to delete something from /home/user dir, for example a Desktop icon and it was succesfully recovered.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-05-2011 08:49 PM
03-05-2011 08:49 PM
Re: backup & restore user home directory include hidden files
>
> tar tvzf /save/user.tar.gz
> I have unpacked the archive using:
>
> tar xzvf user.tar.gz
It's like pulling teeth. The idea was to use
"tar t[...]" to see what the _names_ in the
archive were.
> and it seems to have [...]
> As usual, showing actual commands with their
> actual output can be more helpful than vague
> descriptions or interpretations.
And it's like talking to a wall.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-06-2011 02:00 AM
03-06-2011 02:00 AM
Re: backup & restore user home directory include hidden files
use "tar tzvf" instead of "tar xzvf". t is for testing the archive, which means nothing will be written to the disk, only the contents will be listed. It should list the files with _relative_ paths. If unsure, post the out here.
Unix operates with beer.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-06-2011 04:34 AM
03-06-2011 04:34 AM
Re: backup & restore user home directory include hidden files
Yesterday, was really late I had a lot of other work and didn't have time to use diff.
I just looked into 2 directories, deleted and succesfully recovered some files from the home dir.
Here ist the output of diff:
# diff /save/user /home/user
Nur in /home/user: .adobe.
Nur in /home/user: .bash_history.
Nur in /home/user: .bash_logout.
Nur in /home/user: .bashrc.
Nur in /home/user: Bilder.
Nur in /home/user: .cache.
Gemeinsame Unterverzeichnisse: user/.config und /home/user/.config.
Nur in /home/user: .dbus.
Gemeinsame Unterverzeichnisse: user/Desktop und /home/user/Desktop.
Nur in /home/user: Dokumente.
Nur in /home/user: Downloads.
Nur in /home/user: .esd_auth.
Nur in /home/user: .fontconfig.
Nur in /home/user: .gconf.
Nur in /home/user: .gconfd.
Nur in /home/user: .gnome2.
Nur in /home/user: .gstreamer-0.10.
Nur in /home/user: .gtk-bookmarks.
Nur in /home/user: .gvfs.
Gemeinsame Unterverzeichnisse: user/.ICAClient und /home/user/.ICAClient.
Nur in /home/user: .ICEauthority.
Nur in /home/user: .kde.
Gemeinsame Unterverzeichnisse: user/.local und /home/user/.local.
Nur in /home/user: .macromedia.
Gemeinsame Unterverzeichnisse: user/.mozilla und /home/user/.mozilla.
Nur in /home/user: Musik.
Nur in /home/user: Ã ffentlich.
Nur in /home/user: .su-to-rootrc.
Nur in /home/user: .thumbnails.
Nur in /home/user: Videos.
Gemeinsame Unterverzeichnisse: user/.vmware und /home/user/.vmware.
Gemeinsame Unterverzeichnisse: user/.vnc und /home/user/.vnc.
Nur in /home/user: Vorlagen.
Nur in /home/user: .xsession-errors.
Nur in /home/user: .xsession-errors.old.
They are not 100% identical.
and here is the output tar tzvf:
tar tzvf backup.tar.gz > output.txt
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-06-2011 06:21 AM
03-06-2011 06:21 AM
Re: backup & restore user home directory include hidden files
Would it be asking too much to see what,
exactly, all the commands were that you used
to get this stuff?
> As usual, showing actual commands with their
> actual output can be more helpful than vague
> descriptions or interpretations.
Which part of that was unclear?
This is very tiring.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-06-2011 06:33 AM
03-06-2011 06:33 AM
Re: backup & restore user home directory include hidden files
-----------------------------------
#! /bin/bash
echo 'Backup user home dir'
cd /home
tar cvzf /save/user.tar.gz .
-----------------------------------
extract into /save/user:
# cd /save
# tar xzvf user.tar.gz
compare:
# diff /save/user /home/user