Last active
          August 29, 2015 14:13 
        
      - 
      
- 
        Save f1sherman/c3bfd69600ce81e3d982 to your computer and use it in GitHub Desktop. 
Revisions
- 
        f1sherman revised this gist Feb 9, 2015 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewingThis file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -28,7 +28,7 @@ fi # *** Create the backup file *** VMWAREVM="${VMX%/*}" # Remove the .vmx filename to get the full path to the .vmwarevm bundle cd "$VMWAREVM" tar -czpf "$BACKUP_DIR"/fusion-backup-`date +%Y%m%d-%H%M%S`.tar.gz --exclude '*.vmem' * # *** Delete all but the most recent backup files *** cd "$BACKUP_DIR" 
- 
        f1sherman created this gist Jan 11, 2015 .There are no files selected for viewingThis file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,35 @@ #!/bin/bash # Fail this script if any commands fail (-e) or if any uninitialized variables are referenced (-u) set -e -u # Set the following variables based on your environment VMX='/path/to/file.vmx' BACKUP_DIR='/path/to/backup/directory' VMRUN='/Applications/VMware Fusion.app/Contents/Library/vmrun' NUM_BACKUPS_TO_KEEP=3 # Make sure the VM gets started even if the backup fails trap startvm EXIT START_VM=false function startvm { if $START_VM; then # only start the VM if it was running when we began the backup "$VMRUN" start "$VMX" fi } # *** Shut down the VM if it is running *** if "$VMRUN" list | grep --quiet "$VMX"; then START_VM=true "$VMRUN" stop "$VMX" soft fi # *** Create the backup file *** VMWAREVM="${VMX%/*}" # Remove the .vmx filename to get the full path to the .vmwarevm bundle cd "$VMWAREVM" tar -czpf "$BACKUP_DIR"/fusion-backup-`date +%Y%m%d-%H%M%S`.tar.gz * # *** Delete all but the most recent backup files *** cd "$BACKUP_DIR" (ls -t | head -n $NUM_BACKUPS_TO_KEEP; ls) | sort | uniq -u | xargs rm