Operating System - Linux
1827290 Members
3574 Online
109717 Solutions
New Discussion

Re: how to delete the files that are not part of the backup

 
Maaz
Valued Contributor

how to delete the files that are not part of the backup

I took the backup of the /usr
# tar cvzf /usr.tar.gz /usr

then install some packages that creates some files and directories under /usr

e.g
# rpm -ivh OpenOffice

# rpm -ql OpenOffice

##some individual files created under /usr
/usr/bin/oocalc
/usr/bin/oowriter
/usr/sbin/ooinstdict
/usr/share/applications/base.desktop


##some directories created under /usr
/usr/lib/ooo-2.0
/usr/share/doc/packages/OpenOffice_org

how can I restore the /usr, so that once we restore the /usr via backup(usr.tar.gz), all new directories and files that are not part of the backup(usr.tar.gz) will be deleted

Regards
Maaz
4 REPLIES 4
Steven Schweda
Honored Contributor

Re: how to delete the files that are not part of the backup

Delete everything in /usr, and then do the
restore?
Maaz
Valued Contributor

Re: how to delete the files that are not part of the backup

Hi Thanks Steven Schweda for help.

>Delete everything in /usr, and then do the
restore?

ok, it means that there is no automatic(via tar ) way.
It means that to achieve the target, I first have to boot the system in rescue mode, then delete /usr, then I can restore from the backup

Regards
Mike Stroyan
Honored Contributor

Re: how to delete the files that are not part of the backup

You may get the effect that you describe by using rsync. Either initially create a backup directory with rsync or untar your tar backup into a new /copy/usr directory.
Then use
rsync --dry-run --itemize-changes --archive --delete /copy/user /
to see what changes will be made.
And if all the changes look OK use
rsync --archive --delete /copy/usr /
to actually make the changes.
Be careful with those commands.
And watch to be sure that you have enough room for a second copy of /usr.
Dennis Handly
Acclaimed Contributor

Re: how to delete the files that are not part of the backup

>I first have to boot the system in rescue mode, then delete /usr, then I can restore from the backup

You may be able to restore to another location, then move the directories around.

Or compare the two and delete what you don't want.