How to Tar/Untar Files on a Server without SSH Access
Posted: June 13th, 2012
Author: Ben Heller Details
In an ideal world, web developers would have SSH access to every server we use. But, it’s often the case that clients are with hosts that either don’t allow SSH or make you jump through hoops to enable it. Sometimes clients don’t even know who their host is, or how to access their administrative panel. So, we learn to make the most with what we have available. Media rich sites or WordPress installations with excess themes can either take seconds to move from development to production servers using SCP, or hours using FTP. Upload times are doubled or even tripled when each file has to be sent to the server individually rather than in a neat zip or tarball. Sure we can tar it on our end, but we can’t untar it once uploaded thanks to our crappy permissions. We recently ran into this problem and decided to Google around for an answer. Lo and behold, we stumbled upon this post, which suggests using PHP to untar the archive. While this won’t work on all servers, in our case it happened to be the perfect solution.
if(system("tar -czvf your-fine.tar.gz your-directory/")) echo '<br> <b>Directory compressed successfully!</b>'; else echo '<br> <b>No Donuts for you :(, command has been disabled by host!</b>';
if(system("tar -zxvf your-file.tar.gz")) echo '<br> <b>file uncompressed successfully!</b>'; else echo '<br> <b>No Donuts for you :(, command has been disabled by host!</b>';
Huge props to the original posters for this quick and simple solution. Just save one of the above snippits in a PHP file (we use untar.php), and point your browser to it. If successful, you’ll see the names of the files that have been uncompressed.