Backup crons
These can be used to setup backups in a shared hosting with CPANEL (for example)
Backup a public web directory to a ftp directory
cd ~/public_html && tar -zcvf ~/public_ftp/bkp$(date +\%F).tar.gz .
Dump a database to a ftp directory
| // this will make use of axios interceptors | |
| // and allow axios to retry SERVER errors | |
| // on the initial request we initialize attempt count to 1 | |
| // then on each retry we increment the attempt number | |
| // we send the attempt number to the server as a custom header (x-attempt) | |
| axios.interceptors.request.use((request: AxiosRequestConfig) => { | |
| request.headers.common = { | |
| 'x-attempt': request.headers.common['x-attempt'] || 1 | |
| }; | |
| // @todo add aditional stuff: add random user agent, add proxy, etc |
| <?php | |
| class ExceptionHandler { | |
| public static function retry(\Closure $main, ?\Closure $onFailure = null, $tries = 10) { | |
| $throwable = null; | |
| try { | |
| call_user_func($main); | |
| } catch(\Throwable $throwable) { | |
| // i would advise catching only specfic exceptions here |
Backup crons
These can be used to setup backups in a shared hosting with CPANEL (for example)
Backup a public web directory to a ftp directory
cd ~/public_html && tar -zcvf ~/public_ftp/bkp$(date +\%F).tar.gz .
Dump a database to a ftp directory