backup files to google drive using PHP

前端 未结 3 1317
猫巷女王i
猫巷女王i 2021-02-13 20:42

I have a server and a domain name on GoDaddy.

I want to create a backup for my files to be uploaded on Google Drive

So that all my files and my database have th

相关标签:
3条回答
  • 2021-02-13 21:19

    Dont you miss a hyphen in front of cf in your tar? Isnt it supposed to be tar -cf? You have tar cf. I dont think it recognises it as a command parameter, so there is no file created.

    0 讨论(0)
  • 2021-02-13 21:29

    I was able to run this script successfully while using root access (available in VPS / dedicated servers). But in shared server, where root access is not available, this script is aborted by the server. Shared servers have restrictions on how much maximum time a script can run (usually less than one minute - but depends on the hosting)

    Try to manually run the script in SSH and you will see that the script is aborted by the server which results in no files in the folder created.

    0 讨论(0)
  • 2021-02-13 21:36

    It seem the backup script is unable to find the directory where the site files are stored.

    Quoting from the tutorial you followed to do the backup:

    // User home directory (absolute)
    $homedir = trim(shell_exec("cd ~ && pwd"))."/"; // If this doesn't work, you can provide the full path yourself
    // Site directory (relative)
    $sitedir = "www/";
    

    First ensure that $sitedir is set properly with the relative path (from the home directory) to the site files directory.

    It could be something different than www/, for example public_html/ for a website hosted on GoDaddy.

    If the above is correct try to set $home variable manually with the absolute path of the home directory.


    Update

    $homedir is the home directory and $sitedir is the website root relative to $homedir

    so looking at the code you posted it's quite likely there is a mistake, the two variable should be:

    // User home directory (absolute)
    $homedir = "/home/mhmd2991/"; // <-- FIXED HERE
    // Site directory (relative)
    $sitedir = "public_html/";
    

    This assumes your website root directory is public_html and is located inside your home directory mhmd2991

    Again make sure your website root directory is actually public_html and not www or html or anything else. Check it out using the terminal.

    0 讨论(0)
提交回复
热议问题