Forum
  • Search
  • Member List
  • Calendar
Hello There, Guest! Login Register — Login with Facebook

Pre-upgrade, Online, Full System Backup Script
Thank you for your donation

Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Threaded Mode | Linear Mode
Pre-upgrade, Online, Full System Backup Script
3rd Aug, 2014, 01:42 AM
Post: #1
alangibson Offline
Registered
Posts: 1
Joined: Aug 2014
Reputation: 0
Pre-upgrade, Online, Full System Backup Script
Hello all,

After reading of problems encountered by people upgrading to new Xbian releases, I created a script that allows for point-in-time restore of an Xbian system. It basically creates an an archive of every file on your system. Since Xbian runs on Linux, it's possible to roll back the entire system just by extracting the archive.

The following script creates two scripts, /root/fullbackup.sh and /root/fullrestore.sh. It then runs /root/fullbackup.sh. When it finishes running you can upgrade with confidence knowing that you can go back to the restore point.

I recommend you run each block individually, instead of as a single script. You only have to run this script once.

Code:
# Become root
sudo su

# Make a list of paths to exclude.
# Add yours between EOFs, if needed,
cat > /root/fullbackup-excludes.txt << EOF
proc
sys
dev/pts
lost+found
root
var/cache/apt
var/lib/apt/lists
var/log
home/xbian/.xbmc/temp
media
EOF

# Create the backup script
cat > /root/fullbackup.sh << EOF
set -e
echo Making a 'clean' mount of root file system at /mnt/root
mkdir /mnt/root > /dev/null || true
mount --bind / /mnt/root
echo Running the backup chrooted to /mnt/root
chroot /mnt/root tar -cvpf /root/fullbackup.tar --directory=/ --exclude-from=/root/fullbackup-excludes.txt .
echo Unmounting the duplicate root filesystem
umount /mnt/root
EOF

# Create the restore script
cat > /root/fullrestore.sh << EOF
set -e
echo Making a 'clean' mount of root file system at /mnt/root
mkdir /mnt/root > /dev/null || true
mount --bind / /mnt/root
echo Running restore
mv /root/fullbackup.tar /fullbackup.tar
chroot /mnt/root tar -xvpf /fullbackup.tar
echo Unmounting the duplicate root filesystem
umount /mnt/root
EOF

# and make them executable
chmod 700 /root/fullbackup.sh
chmod 700 /root/fullrestore.sh

# Now run the backup
/root/fullbackup.sh

echo Backup complete. Backup file is at /root/fullbackup.tar.
echo Now you can upgrade your system. Search forum.xbian.org for instructions.
echo
echo If the upgrade succeeds, delete this backup with:
echo     sudo rm /root/fullbackup.tar
echo If it fails, roll back the entire system with:
echo     sudo /root/fullrestore.sh
echo
echo Remember: If Xbian is unable to boot, you can mount the SD card
echo in any Linux computer and do the rollback then.
echo
echo In the future, you can run the backup script directly:
echo     sudo /root/fullbackup.sh
echo
echo Good luck!

# Exit 'sudo su' so we're not root anymore
exit

If you ever want to back up again, you only need to run
Code:
sudo /root/fullbackup.sh

If the upgrade fails, roll the system back with
Code:
sudo /root/fullrestore.sh

Most of this was poached from other sites, some of which are:
http://unix.stackexchange.com/questions/98124/how-to-include-or-add-dev-with-tar-one-file-system
http://www.aboutdebian.com/tar-backup.htm
Find all posts by this user
Quote this message in a reply
5th Aug, 2014, 01:10 AM
Post: #2
IriDium Offline
Inquisitor
******
Posts: 2,025
Joined: Jan 2013
Reputation: 170
RE: Pre-upgrade, Online, Full System Backup Script
Or you could just use the inbuilt btrfs snapshot and rollback function.

I also have a feeling this will not operate as you believe as btrfs is a journalled system, and sync points will be missed with your method.

Thanks for sharing.

Please read before you post
How to post a log file

If you liked my help, click on "Thanks" to show your appreciation.
Find all posts by this user
Quote this message in a reply
« Next Oldest | Next Newest »
Post Reply 


Possibly Related Threads...
Thread: Author Replies Views: Last Post
Brick How to modify "system backup" alert qoop 6 9,044 6th May, 2022 11:46 AM
Last Post: heravinluca
  [PROBLEM] System Backup - Restore Fails husntvar 3 10,883 16th Sep, 2017 04:11 AM
Last Post: Nachteule
  NFS boot and backup script with LVM snapshot Fabio72 0 6,589 13th Feb, 2014 02:14 AM
Last Post: Fabio72

  • View a Printable Version
  • Send this Thread to a Friend
  • Subscribe to this thread
Forum Jump:

Current time: 11th May, 2025, 02:03 AM Powered By MyBB, © 2002-2025 MyBB Group.