On server swap it is needed to move data from one server to another with preserving all attributes and access times.
New server is installed from clean (just for fun and to prevent some old errors from updates or hacks if any 🙂
1. All same packages were installed as on server from which is migrated, here in after as oldserver (did it manually, however can be automated)
2. All same users as on oldserver (also manually) + copying /etc/shadow passwords into new server.
3. Samba conf file transfer with files that hold auth information. In this case smb.conf has passdb backend = tdbsam entry, so had to copy /var/lib/samba/private/passdb.tdb from oldserver
4. mount oldserver’s directory to new server.
# mount.cifs //192.168.1.1/fs /mnt/server-fs/ -o username=USER
it asks password, enter it. Then, when mounted, rsync all files from oldserver to newserver:
the command below will move all files from /mnt/server-fs to /fileserver, with deleting /fileserver/ sub-directories and files if exists.
# rsync -a –verbose –delete-during /mnt/server-fs/ /fileserver
now shutdown old server, change ip and name on new server to old servers one, reboot, and file server can be used.
Update 2024-11-25
If there is wish to sync files without removing:
# mount.cifs //10.10.10.10/fs /mnt/fs10/ -o ro,username=username
# rsync -a -p -o -g –verbose /mnt/fs10/ /fileserverdir/
or
# rsync –archive –perms –owner –group –verbose /mnt/fs10/ /fileserverdir/
after that still require to check permissions on the files wished, comare to old server and set same on new
# chmod -R 775 /fileserverdir
# chown -R user10:gropu10 /fileserverdir