How to retrieve a directory (folder) from Ubuntu Server 14.04 VM without FTP, SCP, or NFS

file-sharingfiles

I am in a bit of a sticky situation. I started my current job a few months ago, and I have a web application running on an apache web server (a simple PHP-based one). I need to update this code to fix some problems in the application, and I'd like to get the code into a proper source code environment (IE. Version Control).

Skipping explanation of irrelevant details, I need to retrieve a directory (folder) from an Ubuntu Server 14.04 (CLI) Virtual Machine without adding or removing any software or other files to the machine. Currently the machine has no FTP or SCP server on it, so I cannot use those. And it's missing the /sbin/mount.nfs helper program to allow the mounting of an NFS share (we have a series of shared folders here that I could potentially use to retrieve the files if I could mount an NFS share).

Currently I only have one idea, which is to insert a USB Flash Drive into the ESXi host that is running the machine, and copying the files to that. However, the machine doesn't have a USB controller, and because it is a production machine I cannot shut it down during the workday to install one, so I'll only be able to do this after business hours. Because of this, (TLDR:) I was wondering if anyone else had any other ideas on how to retrieve a directory from a Ubuntu Server 14.04 VM without FTP, SCP, Mounting an NFS Share, or installing any new files or software.

Edit: Didn't expect all the great responses. Removing my accepted answer for now. I'll assign it elsewhere when I have a good chance to go through these responses and experiment.

Best Answer

As well as saying all the things it doesn't have, what about saying the things it does have? How big is the folder and how much free disk space is there?

Assuming you have no access to the CLI at all, even from the console:

  1. If it's ESXi 5.0 or above, and the server has VMware Tools installed, use PowerCLI and the Copy-VMGuestFile cmdlet to copy files from it.
  2. It's a VM, restore a backup of it somewhere isolated, boot it, make all the changes you like to get at the files.
  3. It's a VM, restore a backup of the disk and download and mount the VMDK file.

Even though you don't have SSH access, assuming you have some kind of access to type commands and manage the server via the VM console:

  1. It's a web server, download the files through a browser
    1. Maybe gzip them into /tmp (memory) and symbolic link into the webserver folder to avoid changing Apache config
  2. Does it have FTP client installed? FTP from the server to somewhere else and upload the files.

    1. Does it have SSH client installed? SCP them from the server to a remote SSH server
    2. Email them to yourself
    3. WGET/Curl POST them to a remote web server upload
    4. TFTP them out
  3. Does it have netcat (nc) installed? You can pipe tar | nc and stream the data to a socket, and use nc | tar on another computer on the network to receive. example

  4. If it's a typical Linux install, it might have Python on it, Python comes with SimpleHTTPServer module which defaults to serving the current directory as a website, run that on a different port to the main webserver and download the files from there.
  5. Script stuffing them into your database as a binary blob into an in-memory table, and then selecting them out from a client maybe relevant
  6. Does the server syslog to a remote destination? Base64 encode the files and stream them into the syslog... ymmv on reading it back.