backup /home (all users)

Hi,

I want to backup all the data in my /home folder/partition (before upgrading).

  1. In How to migrate to a new openSUSE version - openSUSE it is only written how to backup one users data.

If you know the path to your external harddisk, just open a konsole and do:

$ su

   1. cd /home
   2. cp -b -vvv username_to_be_backed_up /media/<folder_of_your_external_harddisk>

How can I backup all users’ data in one folder “home-double”?

  1. Has the external disk have to have any special file system?
    I have an 500 GB disk in fat with some data already on it. Can this be used? Or do I have to make an new (ext3?) partition on my external hard disk to preserve permissions? Do I have to worry about big files under FAT?

  2. Should I make anything to get sure that all data is the same in “home-double” as in “/home”?

Greetings
pistazienfresser


Now I am using (on my Samsung X20) openSuse 11.1 and Gnome 2.24.1 (mostly, 1 account is using KDE) and Kernel Linux 2.6.27.45-01.1-pae. “/home” is on an separated partition (as part of an extended partition). I have also 2 NTFS partitions for Windows XP (System and Data), and a FAT, a root (/) and a swarp partition.

This works fine:

rsync -a -H -x /home/ /media/extdrive/home

The directory /home will not be copied, just its contents. Put whatever you want for the destination. Run this as root.

I have an 500 GB disk in fat with some data already on it. Can this be used?

It depends. fat will loose a lot of info, vfat has no such things as hard links (i think). I would create an ext2 fs on the external drive.

Do I have to worry about big files under FAT?

Yes, unless you have no big files under /home

Possibly there are a lot of files you should backup outside of /home. /var/spool/mail is a candidate, or your mysql database files in /var/lib/mysql. Think twice before you wipe your disk.

As Voodoo says, there are no problems backing up /home - I do it regularly. The problems come if you do not back it up to a Linux friendly filesystem or want to restore it.

Bear in mind that users are known by numbers; so, check each user’s user number and add them to your new setup in the same order. Otherwise, you will find that, when you restore a user’s files, your new installation cannot read any of them because they all have the wrong numbers.

Will this work if you are running it from a LiveCD?

Last time I tried, it didn’t work for me or rather it didn’t provide permissions to copy everything!

I’m trying to backup the /home directory so I can do a fresh install and seperate the /home into its own partition.

You might look at DarGUI or just the dar command line programs.

This allow backup in to zip compressed format in any chunk size you want ie 2 gig to fit on a fat.

Thanks a lot for all your help!

1.1.
I got some failing messages. Mostly:

rsync: readlink_stat("/home/user1000/.gvfs") failed: Permission denied (13)

I think this appeared as I was logged in GNOME as user1000 and had only started a shell and then did the above command as “su”/root.

The analogical message appeared as I logged in KDE as an other user.

Should I log in as root/su before the graphic user log-in starts?

1.2
About rsync general

1.2.1
Where can I find the explanation for this command rsync (internet or in my operating System [man pages - can I print this])?

1.2.2
How can I test if the content is the same (including the hidden folders/files)? How can I compare the data?

1.2.3
How can I modify the command to see what and if anything happens and in the end if I had succeed?

1.2.4.
Can I stop this command (without shutting the shell)?

2.1.
I created an ext3 partition. Hope this will do it.

2.2.
The permissions/owners in ext3/home-double seem to be right.
But only root has now permissions for this ext3 partition. How can i change the second without changing the copy-folder “home-double”?

3.1
Will a system back-up with the tool in the the graphical YaAST do this all?
3.2
Or an image of the root-partition (/) with a partition tool?
3.3
Or an copy of the root-partition with a linux live-cd?

Greetings
pistazienfresser

1.1 Look at the permission of this .gvfs directory:

ls -la | grep gvfs

Probably no read permission for anyone.

1.2.1 man rsync

To print:

man -t rsync | lpr

1.2.2 rsync does this for you. Run it again, add --stats

1.2.3 rsync -av --stats -H -x …

1.2.4 ^C

2.1 yep

2.2 Please show the permission of the directory. A partition has no permission.

3.1 I don’t know

3.2 / 3.3: I suggest to backup /etc /srv /usr /var as well. Or backup the whole system one directory by one. Do not backup /proc or /media and make sure to use the -x option for /var (reason: type ‘mount’ and see what’s mounted under /var).

@dragonbite

Will this work if you are running it from a LiveCD?

I think yes, but you have to mount the respective partitions to suitable mount points. When you boot the LiveCD the /var you see is not the one from your harddisk.

The reason why I ask is that on the system I am trying to reinstall for, the /home directory is in the same partition as the rest, and I think he’s using POP for email (in Evolution) so I want to make sure I get all of those backed up.

To make things more difficult, though, the mouse doesn’t work, and the ethernet doesn’t either. If I remember right it also didn’t auto-mount my USB drive but all of this works with a LiveCD.

Needless to say, I’m going to create a seperate /home partition when I get everything backed up.

Seems to me: the /home/user/.gvfs permission only to the user1003 (owner) not to any group so not to root, too.

In user1003 (KDE, user1003 is a replacement/substitute):


user1003@linux-r0wo:~> su
Password:
*linux-r0wo:/home/user1003 # ls -la | grep gvfs
ls: cannot access .gvfs: Permission denied
d?????????  ? ?       ?         ?                ? .gvfs
linux-r0wo:/home/user1003 # exit
exit*
user1003@linux-r0wo:~> cd /home/user1003
user1003@linux-r0wo:~> ls -la | grep gvfs
dr-x------  2 user1003 users     0 2010-04-21 15:44 .gvfs
user1003@linux-r0wo:~>
user1003@linux-r0wo:~> 

Greetings pistazienfresser

My system allways wants to mount the clone-directory “home/double” as “/media/disk-38”. I unmouted that. So hope that now I don’t have to quit my file manager by force anymore.

Greetings pistazienfresser

That’s it! I can log into his account and do

chmod 777 -R /home/<username>

to make it all accessible, back it up (via LiveCD or otherwise) to a different location and should be able to get everything.

When I move it back into his /home partition I can chmod it back to … um… what are homes usually set for, 700?

I run that again to another folder.
But I think not all files were copied:


...]
Number of files: 29168
Number of files transferred: 23676
Total file size: 8425763650 bytes
Total transferred file size: 8425743431 bytes
Literal data: 8425743431 bytes
Matched data: 0 bytes
File list size: 910275
File list generation time: 0.001 seconds
File list transfer time: 0.000 seconds
Total bytes sent: 8428688683
Total bytes received: 471460

sent 8428688683 bytes  received 471460 bytes  16256818.02 bytes/sec
total size is 8425763650  speedup is 1.00
rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1040) [sender=3.0.4]
linux-r0wo:/home # 


Greetings
pistazienfresser

Ups, I think I made/posted something before reading this:

With each user/username?

Wouldn’t then the solution to backup each /home/usernamex logged in only als usernamex be the easer way (as described in “How_to_migrate_to_a_new_openSUSE_version”)?

Greetings
pistazienfresser

The problem is not backing up so much (there are dozens of ways) but the file system you backup to. Format it to ext3/4 and all permission settings are preserved you can just copy them. Or you could use tar or dar to package the files and preserve the permissions. Now you still have a problem if you backup to FAT since FAT has a 4gig size limit, so you have to be sure that your tar or dar files are not larger then this. So all the problems is trying to backup to an old FAT FS.

Nautilus shows me in /media for /media/disk-38:

Owner: root Permissions:drwxr-r-x

So root is the owner and the only one with writing permissions, everyone else only reading?

So in YaST>Partitioner I click for /dev/sdb2 (ex3) in Edit>Fstab Options on “Montable by user”. Hope this will help…

Greetings pistazienfresser

The Partition I tried to back up to is in ext3.
pistazienfresser

Now I cannot unmout the partition as normal user ;-(
Can I change the writing permissions for that partition/the corresponding folder anyhow (maybe for )?:\

pistazienfresser

Oops missed that.

Ok you seem to have an odd permission setup on the .gsfs directory execute only. What is this directory for? It appears to contain a lot of files.

need to change permission to read also to back it up. Or I guess you could use a dd method since dd is a binary copy or just backup the whole partition. Read man dd and info dd

What a “great” idea, although I wouldn’t even care, if only you mess up your system, but as maybe other people read this thread, I can only hope nobody else will ever try to do the same, insane method.

Why on earth would one use a live CD, giving you “root access by default” and then fiddle around with file permissions?

Even a simple use of cp as root will give you access to all files, just use the correct options for cp to preserve all file permissions and ownerships (see man cp).

The only trouble (no matter what method to be used) is when UID/GID is changing when moving $HOME to another installation, but there is either chown or modifying the UIDs accordingly.