Differences

This shows you the differences between the selected revision and the current version of the page.

synchronizing_disk_images_between_machines 2009/11/02 11:10 synchronizing_disk_images_between_machines 2010/07/16 14:48 current
Line 1: Line 1:
-====== Backing up Disk Images Between Machines ======+====== Backing up Sparse Bundle Images Over SSH ======
If you store you backup within a (encrypted) disk image and you would like to keep this disk image consistent across various systems then you may find the information on this page helpful. If you store you backup within a (encrypted) disk image and you would like to keep this disk image consistent across various systems then you may find the information on this page helpful.
- \\ + \\ \\  
 + 
 +**NOTE** : LBackup 0.9.8r2 and later include a similar script as an example post-action script. The script below is intended for use as a standalone script. If you would like a post action script it is recommended that you start with the example bundled within the LBackup install. Utilizing the bundled version of this script has the advantage of full LBackup integration. This means that the built in and custom [[reporting|reporting options]] of LBackup become accessible.  
 +\\ \\
===== Mac OS X Sparse Bundle Images ===== ===== Mac OS X Sparse Bundle Images =====
Mac OS X 10.5.x and later supports sparse bundle images. These are disk images which are split into smaller files. The advantage of sparse bundle images is that you may use a tool such as rsync to keep your disk image(s) consistent across various systems. Mac OS X 10.5.x and later supports sparse bundle images. These are disk images which are split into smaller files. The advantage of sparse bundle images is that you may use a tool such as rsync to keep your disk image(s) consistent across various systems.
-\\  +\\  \\
==== Copy sparse bundle between machines using rsync. ==== ==== Copy sparse bundle between machines using rsync. ====
Line 17: Line 20:
=== A One Line Version === === A One Line Version ===
-Remember that before coping or update a sparse bundle it is important that you have checked to ensure the images is unmounted.+Remember that before coping or updating a sparse bundle it is important that you have checked to ensure the images is unmounted on both the source and destination. Also, please note that the online version is not as comprehensive as the full script listed below.
  if [ -d /path/to/my_backup.sparsebundle ] && ! [ -d /Volumes/mybackupimage ] ; then ssh backup@remoteserver "df -h" | head -n 2 ; sleep 5 ; /usr/local/bin/rsync_v3 --rsync-path=/usr/local/bin/rsync_v3 -aNHAXEx --delete --progress --stats --protect-args --fileflags --force-change /path/to/my_backup.sparsebundle backup@remoteserver:/backups/ ; else echo "ERROR! : Source not available, or image is mounted ; fi   if [ -d /path/to/my_backup.sparsebundle ] && ! [ -d /Volumes/mybackupimage ] ; then ssh backup@remoteserver "df -h" | head -n 2 ; sleep 5 ; /usr/local/bin/rsync_v3 --rsync-path=/usr/local/bin/rsync_v3 -aNHAXEx --delete --progress --stats --protect-args --fileflags --force-change /path/to/my_backup.sparsebundle backup@remoteserver:/backups/ ; else echo "ERROR! : Source not available, or image is mounted ; fi
Line 45: Line 48:
# #
# Finally, IT IS VERY IMPORTANT that before you call this script you check the disk image is not mounted. # Finally, IT IS VERY IMPORTANT that before you call this script you check the disk image is not mounted.
 +# In addition, this script has only been tested between Mac OS X systems. Use it on other operating systems
 +# at your own risk.
# Various settings which you will want to alter before running this script. # Various settings which you will want to alter before running this script.
Line 55: Line 60:
# Internal Variables # Internal Variables
hdiutil_mounted_status=`hdiutil info | grep "image-path" | grep "${local_sparse_bundle_to_sync}"` hdiutil_mounted_status=`hdiutil info | grep "image-path" | grep "${local_sparse_bundle_to_sync}"`
 +local_system_kind=`uname`
 +remote_system_kind=`ssh ${remote_server_user}@${remote_server_address} "uname"`
 +
 +# Check this is a Mac OS X System
 +if [ "${local_system_kind}" != "Darwin" ] || [ "${remote_system_kind}" != "Darwin" ] ; then
 +  echo "ERROR! : Either the remote or local system is not a Mac OS X system"
 +  exit -1
 +fi
# Okay now we have all the configuration information lets copy / update the sparse bundle. # Okay now we have all the configuration information lets copy / update the sparse bundle.
# Check the image available and is not mounted. # Check the image available and is not mounted.
-if [ -d "${sparse_bundle_to_sync}" ] && [ "${hdiutil_mounted_status}" == "" ] ; then +if [ -d "${local_sparse_bundle_to_sync}" ] && [ "${hdiutil_mounted_status}" == "" ] ; then
  # Print some volume statistics for the remote servers root partition.   # Print some volume statistics for the remote servers root partition.
Line 86: Line 99:
\\ \\ \\ \\
 +
 +===== Moving the Bundle to Other Servers =====
 +
 +The command below will need to modified to your requirements. Essentially, this command is able to sync the disk image between two remote Mac OS X machines. Please keep in mind that this is just one possible approach.
 +
 +    ssh user@src_server.yourdomain.com "/usr/local/bin/rsync_v3 -aNHAXEx --rsync-path=/usr/local/bin/rsync_v3 --delete --progress --stats --protect-args --fileflags --force-change /path/to/src_image.sparsebundle user@dst_server.yourdomain.com:/path/to/this/sparsebundle_backup/
 +
 +  * Keep in mind that with the command listed above any other items in the destination path will be deleted.
 +
 +
 +\\ \\
 +
 +===== Helpful Links =====
 +
 +  * [[http://en.wikipedia.org/wiki/Sparse_image|Wikipedia : Sparse Images]]
 +  * [[http://en.wikipedia.org/wiki/Sparse_image#Sparse%20Bundles|Wikipedia : Sparse Bundles]]
 +  * [[pre_and_post_actions|LBackup Pre and Post Actions]]
 +  * [[http://www.lbackup.org/developer/migrating_backup_sets#relevant_related_notes|Additional rsync options]] , which you may want to add into your version?
 +\\ \\