I am currently trying to compress a directory by using the tar command, however for some reason it doesn't seem to work properly.

I've used this command before on a VPS, so I have experience with using it. I'm trying to transfer files over from my old machine to a new one, yet when I go to compress it, it says this:

tar: Removing leading `/' from member names

The command executed is: tar -czf hub-backup-11-07-17.tar.gz {DIRECTORY} Obviously with {DIRECTORY} replaced with my target file.

Once I've executed the command, the cursor just sits still like in the image, not moving. I've tried leaving it like this until the window times out, but the file is always corrupted. I tried adding -P to the end of the command too. All that did was remove the tar: Removing leading '/' from member names message, but other than that it did the same thing.


| improve this question | | | | |
  • 1
    That means tar is busy creating your archive. Use the -v switch if you want it to be more verbose. The message tar: Removing leading '/' from member names is not an error, tar just removes full paths, probably so it can properly unpack. – Centimane Jul 11 '17 at 11:13

Add -v switch to see what tar is doing. If you have a lot of files tar seems to hang, because it's set in quiet mode by default. Also if your SSH session expires during tar try to use nohup command:

nohup tar -czvf hub-backup-11-07-17.tar.gz {DIRECTORY}

If you trying to transfer files, why are you not using rsync?

| improve this answer | | | | |
  • That's what I was going to do last time I had to do something like this, but the sysadmin said against it, and that I should compress the files and reupload them on the new VPS. Is rsync much faster for that kind of thing then? – Jev4n5 Jul 11 '17 at 11:12
  • So I looked up rsync, and what I found said "It can copy locally, to/from another host over any remote shell". I'm trying to copy from 1 VPS to another VPS, so would rsync still work for this? – Jev4n5 Jul 11 '17 at 11:15
  • 1
    You can use -z with rsync to compress data on the fly. – Sourav Jul 11 '17 at 11:16
  • Yes, of course. Rsync is simpler to use: you don't have to tar files on one machine, copy it, and untar on other machine. If you want to do it just once you can also use scp: scp -r $files_to_move $remote_user@$remote_ip:$remotepath. Maybe your sysadmin worries about network performance ? – mrc02_kr Jul 11 '17 at 11:19
  • 1
    Thank you very much :) I'm using that command you put and it seems to be working well so far! – Jev4n5 Jul 11 '17 at 11:27

Not the answer you're looking for? Browse other questions tagged or ask your own question.