{"id":413,"date":"2016-05-28T09:30:04","date_gmt":"2016-05-28T01:30:04","guid":{"rendered":"http:\/\/www.lanchbury.id.au\/?p=413"},"modified":"2016-05-28T09:39:30","modified_gmt":"2016-05-28T01:39:30","slug":"ncftp-ghettovcb-working-together","status":"publish","type":"post","link":"https:\/\/www.lanchbury.au\/?p=413","title":{"rendered":"ncftp &#038; ghettovcb Working Together"},"content":{"rendered":"<p>I&#8217;m a bit chuffed with my scripting efforts in ESXi, so I thought I would share, I hope someone else might find this useful.<\/p>\n<p>To give a bit of background, I run a VMWare Hypervisor ESXi server, it&#8217;s only a free license version single host, so most of the backup software doesn&#8217;t work that you can buy.  But I have found an awesome script called ghettovcb that utilizes the snapshot and VM console commands to make VM running (and off) backups of my guest VMs.  But obviously I want to get this data off the host, this is where ncftp comes in.<\/p>\n<p>Now I found the code I needed to write to get all my machines backed up and transferred was crazy, and to get these two to work together.<\/p>\n<p>Writing this, I&#8217;ve just thought I should code up all the commands into a single script file, maybe that&#8217;ll be next.  But the below allows you to state a single VM&#8217;s backup folder, or a list with the &#8220;-f textfilewithvmsperline&#8221; command, which I&#8217;ve been able to use the same list from ghettovcb, so I know, if it&#8217;s backed up, it&#8217;ll be uploaded also.<\/p>\n<p>Well, shout out if this has helped you.<\/p>\n<p><code>#!\/bin\/sh<\/p>\n<p>#Where are a few things in your file structure<br \/>\nNCFTP=\"\/vmfs\/volumes\/5TB-RAID5EE\/ncftp\/bin\/ncftpput\"<br \/>\nFTPHOST=\"192.168.100.200\"<br \/>\nFTPUSER=\"Username\"<br \/>\nFTPPASS=\"Password\"<br \/>\nFTPPATH=\"Share\/Folder\"<br \/>\nBACKUPS=\"\/vmfs\/volumes\/5TB-RAID0\/backups\"<br \/>\nSHORTNAMEFORECHO=\"5TB-RAID0\/backups\"<br \/>\n#The rest below shouldn't need changing<\/p>\n<p>#Turn the firewall off, got this permanently set though it's hand to keep it in mind<br \/>\n#esxcli network firewall set --enabled false<\/p>\n<p>#Check a VM name has been given, and advise if not.<br \/>\nif [ \"$1\" == \"\" ]; then<br \/>\n\techo \"Please enter the name of the VM you wish to upload...\"<br \/>\n\texit 1<br \/>\n\telse<br \/>\n\t# Check if a -f command has been issued, for a file list upload<br \/>\n\tif [ \"$1\" == \"-f\" ]; then<br \/>\n\t        echo \"Flag issued for VMs file list to upload, load these and process..\"<br \/>\n\t\tUPLOAD=`cat $2`<br \/>\n\t\t#echo \"$UPLOAD\" && exit 0 #Debugging line to see the list before it is run, this is normally commented out<br \/>\n\t        else<br \/>\n\t        echo \"Single named VM listed to upload, processing..\"<br \/>\n\t        UPLOAD=$1<br \/>\n\tfi<br \/>\nfi<\/p>\n<p>#Okay lets get down to business and process this list or single VM<br \/>\nfor I in $UPLOAD; do<br \/>\n\t#Identify the most recent backup files for the listed VM<br \/>\n\techo \"You've stated $I, looking up the most recent backup.\"<br \/>\n\tLASTBACKUP=`ls -Art $BACKUPS\/$I | tail -n 1`<\/p>\n<p>\t#Check if a location has been found.<br \/>\n\tif [ \"$LASTBACKUP\" == \"\" ]; then<br \/>\n\t\techo \"Results of the search have failed, please check the listed name and try again.\"<br \/>\n\t\telse<br \/>\n\t\techo \"The last backup location is $SHORTNAMEFORECHO\/$I\/$LASTBACKUP\"<br \/>\n\t\t# Use this location and upload it to Icharus NAS<br \/>\n\t\techo \"Beginning upload of folder\"<br \/>\n\t\t$NCFTP -u$FTPUSER -p$FTPPASS -E -R $FTPHOST $FTPPATH $BACKUPS\/$I\/$LASTBACKUP<br \/>\n\tfi<br \/>\ndone<\/p>\n<p>#Should be all done, suggesting so...<br \/>\necho \"Complete\"<\/p>\n<p>#Turn the Firewall back on<br \/>\n#esxcli network firewall set --enable true<\/code><\/p>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;m a bit chuffed with my scripting efforts in ESXi, so I thought I would share, I hope someone else might find this useful. To give a bit of background, I run a VMWare Hypervisor ESXi server, it&#8217;s only a free license version single host, so most of the backup software doesn&#8217;t work that you &hellip; <\/p>\n<p><a class=\"more-link btn\" href=\"https:\/\/www.lanchbury.au\/?p=413\">Continue reading<\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[1],"tags":[],"class_list":["post-413","post","type-post","status-publish","format-standard","hentry","category-uncategorized","item-wrap"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p7tC7P-6F","jetpack-related-posts":[],"_links":{"self":[{"href":"https:\/\/www.lanchbury.au\/index.php?rest_route=\/wp\/v2\/posts\/413","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.lanchbury.au\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.lanchbury.au\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.lanchbury.au\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.lanchbury.au\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=413"}],"version-history":[{"count":4,"href":"https:\/\/www.lanchbury.au\/index.php?rest_route=\/wp\/v2\/posts\/413\/revisions"}],"predecessor-version":[{"id":417,"href":"https:\/\/www.lanchbury.au\/index.php?rest_route=\/wp\/v2\/posts\/413\/revisions\/417"}],"wp:attachment":[{"href":"https:\/\/www.lanchbury.au\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=413"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.lanchbury.au\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=413"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.lanchbury.au\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=413"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}