Task: To provide facility to upgrade the system remotely or add new features.
What I am supposed to do Create a back up of current environment of target machine and if upgrading fails at any stage, then revert back to original environment.
Say my directory structures are something like this:
/home/user/project1/....bla bla
project 1 contains symbolic links, hard links, executable files of software and firmware etc.
My dilemma
Should I use strategy 1 or 2?
Should I copy the whole current environment and revert back if upgrading fails.
example -> cp -p -r /home/user/project1/* /home/user/project1_backup/
if upgrading fails -->
mv /home/user/project1_backup/ /home/user/project1
Should I tarball the whole environment and untar it if upgrading fails. To create tar ball, I'm a bit skeptical about preserving symbolic links and hard links .. and same while untar it.
Could some please provide concrete answer which method I should follow and if I go with tar ball approach what will be the bash command.
As far as I know tar -cvfz
for creating tar gunzip will not preserve the links and permissions and similarly while untarring the tar ball.
Please throw some light?
I would use the second option: create a tarball; because tarballs have some positive points:
And here is the command:
tar --preserve-permissions --preserve-order -jc /path/to/your/folder > /path/to/your/backup_file.tar.bz2
This shall preserve your permission, your symlinks. And for the hardlinks, I give you this link (http://www.gnu.org/software/tar/manual/html_node/hard-links.html)
(but by default, tar preserve hardlinks)
Don't forget to test your tarball before upgrading your system !!
(you will avoid almost all lose of data in the case of the archive isn't correctly created)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With