Backup Restore: UID & GID are present
Hello,
I have restored a backup of some files onto my server. The server is no empty of users, but the backups are restored using the right UID's and GID's. Is there a trick to recreating all the users and associating them with their UID's and GUID's easily? Here is an example: drwxrwx--x 3 3039 3039 4096 Oct 23 10:56 group13 drwxrwx--x 3 3040 3040 4096 Oct 23 10:56 group14 drwxrwx--x 3 3041 3041 4096 Oct 23 10:56 group15 drwxrwx--x 3 3042 3042 4096 Oct 23 10:56 group16 drwxrwx--x 3 3043 3043 4096 Oct 23 11:12 group17 drwxrwx--x 3 3044 3044 4096 Oct 23 10:56 group18 drwxrwx--x 3 3045 3045 4096 Oct 23 10:56 group19 drwxrwx--x 3 3028 3028 4096 Oct 23 10:55 group2 drwxrwx--x 3 3046 3046 4096 Oct 23 10:56 group20 drwxrwx--x 3 3029 3029 4096 Oct 23 10:55 group3 drwxrwx--x 3 3030 3030 4096 Oct 23 10:55 group4 drwxrwx--x 3 3031 3031 4096 Oct 23 10:56 group5 drwxrwx--x 3 3032 3032 4096 Oct 29 12:11 group6 drwxrwx--x 3 3033 3033 4096 Oct 23 11:17 group7 drwxrwx--x 3 3034 3034 4096 Oct 23 10:56 group8 drwxrwx--x 3 3035 3035 4096 Oct 23 10:56 group9 At one time, 3039 = group13:group13. Any help would be greatly appreciated, does someone already have a script? --B |
If you had also backed up the /etc/passwd & /etc/shadow files, you could restore them somewhere and extract the regular users and then append those lines to your current files.
This bit isn't tested. I just saved your sample to a file and used awk to display the uid, gid and user fields. This will create inactive accounts (no passwords) disabled with "!" in the passwd field. Code:
while read uid gid user; do |
Quote:
I have the shawdow and passwd files here in my backup. So I can just append the lines for the regular users to the end of the existing files and that will be that? |
Quote:
I ended up using this script, thanks to your information. I was able to build it: #This is only useful if authenication takes place from an external source like LDAP, and the user does not have a password stored on the local machine. ls -la /home > USERS cat USERS | awk '{print "groupadd -g", $4, $9}' > part1.sh cat USERS | awk '{print "useradd -u", $3, $9, "-g", $9 }' >> part1.sh chmod 775 part1.sh echo "Now go check Part1.sh, and remove any bad users" echo "." echo "Once checked, then run ./part1.sh" |
All times are GMT -5. The time now is 08:16 AM. |