LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 10-21-2023, 06:07 PM   #1
pizzipie
Member
 
Registered: Jun 2005
Location: Hayden, ID
Distribution: Ubuntu 20.04
Posts: 441

Rep: Reputation: 12
Using backed up "Home" dir for user "Home" dir in another Computer


Hi,

Using Ubuntu 22.04.1 on two different machines.

I have a backed up 'home' dir from computer 'A' - say 'homeA.bak'.

I have another computer 'B' which already has a 'home' dir for the principle user as set up upon installation , call him 'usrB'.

Now I want to create a new user 'usrB-2' without a 'home' dir and then create a 'home' dir for 'usrB2' which will be 'homeA.bak'.

I assume from what I read that 'home' directories are not like 'regular' directories' in that they contain other files in them that make them 'home' directories. ie: you just can't make a directory called 'home' and copy backed up files to it and have it act like a 'home' directory.

Can someone tell me how to do this properly? Thanks in advance,
R
 
Old 10-21-2023, 07:48 PM   #2
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,760

Rep: Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931
Yes a home directory contains a bunch of configuration files and other stuff in hidden files and directories but that can also be backed up. If user b has the same uid,gid then restoring via a file is doable otherwise rsync should work.
 
Old 10-21-2023, 08:16 PM   #3
computersavvy
Senior Member
 
Registered: Aug 2016
Posts: 3,345

Rep: Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484
It is also quite possible to create the second user with their own directory.
Then restore the content of the backup to the new home directory. Note that you would want to restore the content and not the full directory plus content so you avoid unwanted nesting of directories.
Once that is done then the only thing that should be required would be to use chown to ensure the restored content is properly owned by the second user.

Another possibility would be to restore the backup into /home (full, including users home directory [making sure there is no name conflict with already existing home directories]). Once restored you could remove the users home directory, then rename the restored home directory to the directory name that was created for your new user. Again the final step would be using chown to restore ownership to the new user.

Example - the backup was for user john on machine A.
The second newly created user on machine B is Jack.
Restore the backup into /home on machine B which would create the directory tree /home/john.
Delete the directory tree /home/jack so that directory name does not exist.
Rename /home/john to /home/jack
chown -R jack:jack /home/jack
Your new user jack now has the entire directory tree that originally belonged to john on machine A.
 
Old 10-22-2023, 04:27 AM   #4
fatmac
LQ Guru
 
Registered: Sep 2011
Location: Upper Hale, Surrey/Hants Border, UK
Distribution: Mainly Devuan, antiX, & Void, with Tiny Core, Fatdog, & BSD thrown in.
Posts: 5,506

Rep: Reputation: Disabled
Create the /home directory for your new user, then just copy all the user files of your back up into it.

If the new user has a different ID, just chown the whole user directory recursively.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
copying files from home dir to another dir from another dir in a lower dir chomito44 Linux - General 5 10-19-2013 06:18 PM
Move files contained in source dir to destination dir, but not source dir itself unixunderground Linux - Software 3 09-20-2013 11:17 AM
tar dir and sub dir removing files but not existing not empty dir j-me Linux - General 2 08-12-2013 11:37 AM
exclude parameter of rsync- 'dir' vs "dir" vs dir rng Linux - General 5 06-13-2012 01:47 AM
Command to display /dir, /dir/sub, /dir/sub/files knockout_artist Linux - Newbie 9 10-25-2007 02:57 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 07:58 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration