How to make so that the full folder structure of the site is archived? I only archived files that I highlighted in the screenshot.

enter image description here

$sitedir = 'E:/OpenServer/domains/cms/*'; $filebackup = 'file_backup_'. date("Ym-d_H-is") .'.tar.gz'; shell_exec("tar cvfz $filebackup $sitedir --exclude=$filebackup"); 

I'm testing everything on the Open server.

  • perhaps the command parameters are wrong, try czf instead of cvfz - Marsel Arduanov
  • And if cvzf ? - andreymal
  • Both options - does not help. can tar generally archive the entire folder structure? - damager9408
  • Of course it can-- - andreymal
  • I tried on the working site - shell_exec ("tar -cvzf $ filebackup $ sitedir --exclude = $ filebackup"); It works, but on open servere it still does not work. It’s all about the open server, as I understand it (I’m not particularly into the settings). - damager9408

1 answer 1

if the file is in the cms folder

replace

 $sitedir = 'E:/OpenServer/domains/cms/*'; 

on

 $sitedir = '*'; 

and will archive with subfolders

  • Bad advice. Guaranteed problems with special characters and the flying of POSIX (and not only, since this is Windows) is right - andreymal
  • But to replace the contents of the answer to a completely different is very mean - andreymal
  • Well no. The script is inside ../cms/ - damager9408
  • >> But to replace the contents of the answer with a completely different one is very mean - it’s not so mean that the rules of this site read, did you read them? - Lesiuk Alexey
  • The code written above works, did you check it? .. if the script in the same folder is simply replaced with $ sitedir = '*'; - Lesiuk Alexey