Tar backups to tape drive

Prof.Merlin

Expert Member
Joined
Aug 2, 2006
Messages
1,682
Hi All

I have a nice little script which copies data from all over to one server and then creates a tar onto a tape. This has no issues and restore works.

Issue is when I try do a restore onto another machine, the restore fails with the following errors:
  • tar: var/mail: Cannot change ownership to uid 0, gid 0: No such file or directory
  • Directory renamed before its status could be extracted

I understand the first error, but not the second. I don't have a solution to any. Is there a switch that I should be using to solve this issue.

The code I am using to create the tar is:
tar -czf /dev/st0 filestobackup

To restore I am using:
tar xzf /dev/st0 filetoextract destination

Thanks
 

Kroks

Well-Known Member
Joined
May 27, 2009
Messages
158
It seems that there is a permissions issue. Just a few questions.
- Is the backup being run as root? and are you restoring as root?
- What were the original permissions of the files that you backed up, and also the destination folder where you are restoring to. Owner / permissions.
- You stated that the backup first copies the files to a "staging" area and then you back it up. What is the Owner / permissions on that.
- check if what you are backing up maby has a simbolic link.
- Are you using the same version / distro on both servers?
 
Last edited:

Prof.Merlin

Expert Member
Joined
Aug 2, 2006
Messages
1,682
It seems that there is a permissions issue. Just a few questions.
- Is the backup being run as root? and are you restoring as root?
- What were the original permissions of the files that you backed up, and also the destination folder where you are restoring to. Owner / permissions.
- You stated that the backup first copies the files to a "staging" area and then you back it up. What is the Owner / permissions on that.
- check is what you are backing up maby has a simbolic link.
- Are you using the same version / distro on both servers?

Hi

-Yes. Restoring as root. But mounted a directory on another server using sshfs as root.
-Backing up home directories so permissions for each directory is different
-Only some files are in a 'staging' area. The home directories I copy as it, which is also the ones giving issues
-No. Centos on backup machine, ubuntu on restore. Although I am restoring to the ubuntu machine from centos
 

Kroks

Well-Known Member
Joined
May 27, 2009
Messages
158
mmm,

Am I correct is saying that you are restoring to a remote server, mounted on a sshfs mount? If so can you maby try and restore it locally?
Just want to confirm that it is not the sshfs that is causing the problems.
 

Prof.Merlin

Expert Member
Joined
Aug 2, 2006
Messages
1,682
I have done a restore locally with no issues. Seems to permissions on another machine.
 

unskinnybob

Expert Member
Joined
May 30, 2007
Messages
3,788
I recall doing all restores using tar xvf. eXtract, Verbose, toFile - Can't remember for the life of me. Many moons ago.

That was on Solaris.
 

Kroks

Well-Known Member
Joined
May 27, 2009
Messages
158
Ha I thought so.

OK that you can do is to try and use the p switch i.e. tar xzpf /dev/st0 filetoextract destination . That forces to keep the original permission.
I think that the tar is extracting the files with it's original permission, and then trying to make root:root (wheel) the owner. Hence the "Cannot change ownership to uid 0, gid 0. " You might find that the data is actually being extracted, but because the original owner/permission is not "valid" on the target server it might be blocking access to user root to take ownership of the extracted files, so the process dies.
You can also test if you can copy files from the local server to the remote one. Similar to how tar would do it. I have a suspicion that it might give a error. If it doesnt give a error try and give the file the owner that doesnt exist on the target server. check the /etc/passwd file to see that UID numbers. This is because the the original file that you are extracting might have owner "joe" and "joe" doesnt exist on the target server. This might even be a issue with server security, maby SELinux or Apparmor or similar.

Unix/Linux user permission is not too complex, but it can be a lot less forgiving than Windows permissions.

I hope this helps.
 

Kroks

Well-Known Member
Joined
May 27, 2009
Messages
158
BTW, if you want to auto eject the tape you can run
mt -f /dev/st0 offline

always a nice feature.
 
Last edited:
Top