Skip to content

Instantly share code, notes, and snippets.

@on4r
Created February 14, 2019 10:32
Show Gist options
  • Select an option

  • Save on4r/030ae3a4c4f280280b1c542025ca0bff to your computer and use it in GitHub Desktop.

Select an option

Save on4r/030ae3a4c4f280280b1c542025ca0bff to your computer and use it in GitHub Desktop.
FTP only? No SSH? » Archive you webspace with this script
<?php
// https://www.emvee-solutions.com/blog/create-tar-files-archive-files-server-using-php-script/
try {
//make sure the script has enough time to run (300 seconds = 5 minutes)
ini_set('max_execution_time', '300');
ini_set('set_time_limit', '0');
$target = isset($_GET["targetname"]) ? $_GET["targetname"] : 'archive.tar'; //default to archive.tar
$dir = isset($_GET["dir"]) ? $_GET["dir"] : './.'; //defaults to all in current dir
//setup phar
$phar = new PharData($target);
$phar->buildFromDirectory(dirname(__FILE__) . '/'.$dir);
echo 'Compressing all files done, check your server for the file ' .$target;
} catch (Exception $e) {
// handle errors
echo 'An error has occured, details:';
echo $e->getMessage();
}
?>
@on4r
Copy link
Author

on4r commented Feb 14, 2019

How to use

  1. Download the script, save it as archiver.php
  2. Upload the script to your server
  3. Go to yourwebsite.com/achiver.php to call the script

Found on www.emvee-solutions.com

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment