Skip to main content

I had generated a backup of key directories on the server - see Create a Ubuntu backup shell script.  With a backup in hand, now it was time to test how to unpack a backup and overwrite the directories.

First I unpacked the backup to a temporary directory tmp-cc.

Now I wanted to replace several of the directories on the server.  Starting with home, var and etc.   But what is an efficient method to overwrite a directory?   Also removing any directories that aren't in the copied version.  Initially, I tried

cp -rlf tmp-cc/home/ home

And other varying forms of cp and mv.  None had the impact I was seeking.  Instead, I began to investigate rsync

rsync -a --delete tmp-cc/home/ home/
-a is 'archive mode', which copies faithfully files in foo/ to bar/
--delete removes extra files not in tmp-cc/home/ from home/ as well, ensuring home/ ends up identical
-vh verbose and human-readable

If you want to see what it's doing, then add -vh as noted in the table above

Note: the slash after foo is required, otherwise rsync will copy tmp-cc/home/ to home/home/ rather than overwriting home/ itself.

Related articles

Andrew Fletcher18 Mar 2024
Resolving CVE-2022-48624 less issue
To resolve the CVE-2022-48624 vulnerability on Ubuntu using Nginx, it's crucial to understand that the issue lies within the "less" package, not Nginx itself. The vulnerability affects "less" before version 606, where close_altfile in filename.c in less omits shell_quote calls for LESSCLOSE,...