I am creating a debian package where i have written preinst and post inst scripts. In my preinst scripts, am taking backup of some file using "sudo". But actual owner of these file are some other customized user. Hence when i take backup or restore these files then, user is changing to root.
How to define my custom user to copy or move files inside pre install script of debian package?
if [ -e /home/custom/file.txt]; then
sudo cp -v /home/custom/file.txt /home/custom/backup/file.txt
exit 1
fi
After executing above code in pre inst script, owner of file.txt changes to root