Created
February 14, 2019 10:32
-
-
Save on4r/030ae3a4c4f280280b1c542025ca0bff to your computer and use it in GitHub Desktop.
FTP only? No SSH? » Archive you webspace with this script
This file contains hidden or 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
| <?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(); | |
| } | |
| ?> |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
How to use
archiver.php