Results 1 to 4 of 4

Thread: Copy files for backup

  1. #1
    Join Date
    Oct 2010
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Copy files for backup

    I have a file on my website that I need to make a backup of every 30min. So what I was going to do is make a cron job and have it run a php script that would make a copy of a file. I tried:

    <?php
    $file = 'entries.txt';
    $newfile = 'backup.txt.bak';

    if (!copy($file, $newfile)) {
    echo "failed to copy $file";
    }
    ?>


    but that is disabled for security purposes.

    I just started out with php and dont really know that much, so could someone please guide me to completing this task?

  2. #2
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    If that's disabled then other similar functions might be disabled. fwrite() and related functions could do this, or you could try exec() and other system functions to run linux commands directly-- if these aren't also disabled.

    If you run phpinfo(); (on an otherwise empty page) you may get some feedback about what is and what is not allowed.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  3. #3
    Join Date
    Oct 2010
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Better yet... How could I email the file to my self. (attaching a file in the mail function)?
    Last edited by jtf107; 10-26-2010 at 11:39 PM.

  4. #4
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    That's very complex. There are lots of tutorials for it but it's not something I'd recommend for a beginner (as you said in your last post).

    If you need this right now, I'd suggest looking for an existing script, though many may rely on other functions that are disabled-- you may need to get a different hosting account that allows full access. It shouldn't be hard to find one for about $5-10/mo (and up).
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •