• Welcome to Overclockers Forums! Join us to reply in threads, receive reduced ads, and to customize your site experience!

SOLVED tarball to be created in another directory

Overclockers is supported by our readers. When you click a link to make a purchase, we may earn a commission. Learn More.

Odyssey1942

Registered
Joined
Jul 12, 2006
I want to zip my /home directory, but have the tarball file created outside of /home to avoid a "double compression" problem.

I have tried several variations of tar with various switches and destinations, but nothing wants to work. Have read the tar man pages and they are way too technical for me, and google is not being helpful.

Could I trouble someone to please give me the line of code to collect everything in my current /home and zip it into one tarball,

and have the tarball show up in /opt (where there is space for it (or if /opt is not a good place to put it, your suggestion)?

Any explanation of what any recommended switches accomplish in simple English will be greatly appreciated.

I think the basic tarball creation should be the following, which please confirm, but how to get the tarball created in /opt directory?

tar -czvf currenthome.tar.gz /home

Many thanks
 
You should be able to either explicitly state that /opt is the output directory:
Code:
tar -czvf /opt/currenthome.tar.gz /home
or to change to /opt before running the command:
Code:
cd /opt
tar -czvf currenthome.tar.gz /home

If these don't work, what errors do you get?

JigPu
 
JigPu, The first option seems to be working like a charm. Lines of text are flying by on the screen.

Many thanks for the quick reply.
 
Helpful hint:
If you want to extract to another you would do the following

Code:
tar xvzf sometarfile.tar.gz -C /<new destination>

I use this a lot
 
The guidance did indeed work, but this is becoming more complicated.

I thought that I had deleted the old home.tar.gz from the /home directory, but had not. So the new tar file of /home contained the previous tar file. (The new tar file is 32GB!)

So I deleted the new tar file from /opt, then deleted the old home.tar.gz from /home. Then emptied the trash.

Then logged out and at the intitial login screen, pressed Alt-Ctrl-F1 to bring up a command line terminal. But Alt-Ctrl-F1 now doesn't work.

I rebooted a couple of times, then powered off, but Alt-Ctrl-F1 still doesn't work. So I then logged in, brought up a console and tried to create the tar from the console, but it failed. Arrrrrgh!

So now I need to get Alt-Ctrl-F1 working again at the Login screen. Any ideas?

EDIT: Found it! Ctrl key on keyboard failed! What are the chances of that? Thanks.
 
Last edited:
Much more complicated. Still bashing away and seem to be no closer to success. In fact I am in a terrible muddle. Here is a summary of the history:

in old computer I ran:
Code:
tar -czvf /opt/username120307.tar.gz /username
(put into opt to keep from creating the tarball within the directory being zipped),

then from within /opt
Code:
scp username120307.tar.gz /[email protected]
which failed with error message: "permission denied, please try again" (i.e., would not accept my password [which I know is correct and retried several times]), then
Code:
scp username120307.tar.gz /[email protected]
which worked (so for some reason, /home and /username on the new computer seem to need different passwords?)

Then in /home at the new computer, I renamed /username /username2, moved username120307.tar.gz into /home and unpacked it.

Now when I boot up new computer, I put in my password at login as normal, but then get the following three error messages on a blank desktop (color only, no icons)

1)Could not update ICEauthority file /home/username/ICEauthority
2)There is a problem with the configuration server. (/usr/lib/libgconf2-4/gconf-sanity-check-2 exited with status 256)
3)Nautilus could not create the following required folders: /home/username/Desktop, /home.username.nautilus (Before running Nautilus, please create these folders, or set permissions such that Nautilus can create them.)

So can anyone see anything in the above that caused this whole process to go pear shaped?

Secondly, why do /home and /username on the new computer seem to need different passwords in order to scp the files over?

I am very much a noob at the command line, so more information rather than less will be so appreciated (I hope to learn something from all this) Thanks.
 
Last edited:
If you run:

Code:
scp whatever.tar.gz [email protected]

You will actually be copying it to a local file on the same computer called [email protected]

Your whole syntax seems to be wrong...

Correct syntax is:

Code:
scp filename user@host:path_on_the_host

Optional parameters are user (if you have the same username on the other end) and path (without it the file will go in your own home directory on the other host). If you don't include the user parameter then you don't include the @ charecter, but if you don't include the path you still have to add : after the hostname / ip or it will copy it to a local file.

So looking at the two scp commands you put they should have probably been:

Code:
scp username120307.tar.gz 192.168.0.104:/home

Which would try to copy the file under /home on the remote computer (which would probably fail as writing under /home would require root permissions)

and

Code:
scp username120307.tar.gz [email protected]:

which would copy the file under /home/username on the remote host (assuming home directories are there on the server).

You should only have one password for a username on the computer, but my guess is that either while making the scp to the local computer (which I recollect does not prompt for a password) or defining the path in place of the username you where getting password problems, for example if you did this:

Code:
scp username120307.tar.gz /[email protected]:

It would try to log into the remote computer as user "/home" meaning the password would fail.

edit:

For completeness here is something I wrote up as a reminder when I was doing something similar a few years ago, only the local machine did not have enough space to store the created tar file. I just piped creation of the tar file over SSH to the remote host:

Code:
tar czvf - folder/ | ssh foo@bar "cat > /tmp/foo.tar.gz"
 
Last edited:
dropadrop,

Thanks for yours which I am studying and have a couple of questions.

In your first example, the result of my doing that was to transfer (copy?) the tarball into the existing user on NEW computer (user in both computers is robert)

The actual code I first tried to use was;
Code:
scp robert120307.tar.gz /[email protected]
and when I did, it asked for a password. I gave my normal password, but was denied access. BTW, I tried it several times, checked the caps key, etc, so I am sure it was my normal password for robert on the NEW computer

So then I tried
Code:
scp robert120307.tar.gz /[email protected]
. Password again requested, but this time accepted, and the file robert120307.tar.gz turned up in /home/robert on NEW.

I then renamed robert as robertorig, moved the tarball into /home, and extracted it. It created a user (/home/robert) just as I expected.

So I rebooted, logged in, but was presented with the three error messages above. I closed each and was then left looking at an Ubuntu orange/brown background colour.

Should I have omitted the renaming step and just unpacked it in /home/robert?

I have other questions about yours, but thought it might be easier to go one step at a time. I look forward to your further advice. Thanks.
 
dropadrop,

The actual code I first tried to use was;
Code:
scp robert120307.tar.gz /[email protected]
and when I did, it asked for a password. I gave my normal password, but was denied access. BTW, I tried it several times, checked the caps key, etc, so I am sure it was my normal password for robert on the NEW computer

So I rebooted, logged in, but was presented with the three error messages above. I closed each and was then left looking at an Ubuntu orange/brown background colour.
I think you misunderstand let me give you an exact example
Assume I have some tar in opt, and my destination is a remote computer
Code:
scp /opt/stratus_home.tar.gz stratus@stratus-desktop:/opt

This will put stuff from my current opt onto my desktop in the /opt/. This assumes that the user "stratus" has write permissions to the /opt directory on stratus-desktop

Also, just extracting the home directory does not create a user, it simply creates a folder. It is always good practice to make sure the user ID's match the new system (for example if on startus-laptop my home was owned by stratus with an ID of 500, but on my desktop user "stratus" had an ID of 501, user stratus on the desktop would not be allowed to use the /home/stratus folder I just extracted

To make sure you have the proper permissions you should do the following

Code:
sudo chown -R stratus:stratus /home/stratus

This will reset the user ID's in the folder specified (and all sub folders)

additionally you did not post (or I may have missed it) what three errors you encountered
 
OK, I think I have it now and the proposed solution worked. Thank you for your patience in this.

BTW, the earlier posting contained this:

Now when I boot up new computer, I put in my password at login as normal, but then get the following three error messages on a blank desktop (color only, no icons)

1)Could not update ICEauthority file /home/username/ICEauthority
2)There is a problem with the configuration server. (/usr/lib/libgconf2-4/gconf-sanity-check-2 exited with status 256)
3)Nautilus could not create the following required folders: /home/username/Desktop, /home.username.nautilus (Before running Nautilus, please create these folders, or set permissions such that Nautilus can create them.)
 
Hey mate,

for those who come after you, would you mind specifying which solution(s) worked for you since there were several in this thread :D

cheers
 
Last edited:
Yes, sorry about that. I was indeed all over the map. It was Stratus' suggestion of
Code:
sudo chown -R stratus:stratus /home/stratus
which in my case was:

Code:
sudo chown -R robert:robert /home/robert
In spite of appearances, this has been a huge learning curve for me. Thanks to all who helped me through to a solution.
 
Hopefully the part about UIDs was clear. That is a fundamental part of working with linux
 
In complicated cases you can always decouple tar generation and compression or decompression/extraction, for example if you want to use a different compression program, compression options etc:
tar cvf - something | gzip -c9 >destfile.tar.gz
( cd somewhere; tar cvf - something ) | ( cd somewhere_else; pbzip2 -c9 >destfile.tar.bz2)
Yeah that last one could be done with tar cCvf I know. Just wanted to demonstrate how to use a subshell with multiple commands there.
Similar for decompression:
pbzip2 -dc <tarfile.tar.bz2 | ( cd somewhere; tar xvf - )
I have had cases where double buffering improved performance:
dd if=tarfile.tar.bz2 bs=64M | dd bs=64M | pbzip2 -dc | tar xvf -
etc...
 
Back