Simple ruby script to backup a home directory via rsync and suspend/start VMs before/after
This file contains 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 characters
#!/usr/bin/env ruby | |
REMOTE_HOST = "" | |
USER = "" | |
SOURCE = "" | |
DESTINATION = "backup/" | |
vm_list = `vmrun list`.split("\n") | |
vm_list.shift | |
puts "[*] Suspending Virtual Machines" | |
vm_list.each do |vm| | |
`vmrun -T ws suspend '#{vm}'` | |
end | |
sleep(vm_list.count * 10) | |
puts "[*] Backing up #{SOURCE}" | |
system "rsync -e ssh -avz --delete-after #{SOURCE} #{USER}@#{REMOTE_HOST}:#{DESTINATION}" | |
sleep(vm_list.count * 15) | |
puts "[*] Starting Virtual Machines" | |
vm_list.each do |vm| | |
`vmrun -T ws start '#{vm}'` | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment