Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


Looking for PHP Backup script.
New on LowEndTalk? Please Register and read our Community Rules.

All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.

Looking for PHP Backup script.

Anyone know and have experience with a PHP backup script?

My setup is: I have a site on shared webhosting. I need the files and MySQL files backupped up to a remote VPS automaticly every day. Now I know some but those arent automatic or encrypted and encryption is a must for me. Sending over FTP is also a nono.

Something like a password protected .zip backup or maybe something better and safer.

So anyone know a solution?

Comments

  • edited April 2016

    I would not use PHP for a backup script.

    Something like rsync over ssh would be the way to go.

    Along the lines of:
    https://www.digitalocean.com/community/tutorials/how-to-create-an-off-site-backup-of-your-site-with-rsync-on-centos-6

    Edit: The link points to a CentOS system, but the basic idea is the same on any 'nix system.

  • How about CDP?

  • BradBrad Member

    http://cdp.me should do what you need.

  • @Brad said:
    http://cdp.me should do what you need.

    @Magbanua

    Thanks. I will try that out.

  • ReyRey Member
    edited April 2016

    I wrote few times ago a little backup script in bash for my website.. It can be used with a cronjob, it backup files and mysql, encrypt and send all to dropbox with another bash script. Hope it will help you. I'm not a programmer so if anyone more expert than me want to comment :)

    Need: https://github.com/andreafabrizi/Dropbox-Uploader

    edit: Unfortunately the code with copy&paste is a shit..

    !/bin/bash

    td=tmpbackup
    giorno=$(date +%d)
    file=hd-$(date +%Y_%m_%d-%H_%M)
    passwd=pass-$(date +%Y_%m_%d-%H_%M)
    cart=$(date +%Y_%m)

    /usr/bin/mysqldump -u user -ppassword db > $td/$file.sql
    tar czfP $td/$file.tgz $td/$file.sql

    MATRICE="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"

    LUNGHEZZA="8"

    while [ "${n:=1}" -le "$LUNGHEZZA" ]

    do
    PASS="$PASS${MATRICE:$(($RANDOM%${#MATRICE})):1}"

    let n+=1

    done
    echo "$PASS" > pass.key

    openssl enc -aes-256-cbc -salt -pass file:pass.key -in $td/$file.tgz -out $td/$file.enc

    openssl rsautl -encrypt -pubin -inkey pub-rsa.key -in pass.key -out $passwd.enc

    rm pass.key

    ./dropbox_uploader.sh upload $td/$file.enc /db-$cart/$giorno/$file.enc
    ./dropbox_uploader.sh upload $passwd.enc /db-$cart/$giorno/$passwd.enc

    rm $td/$file.tgz
    rm $td/$file.sql
    rm $td/$file.enc
    rm $passwd.enc

  • Rey said: I wrote few times ago a little backup script in bash for my website.

    If you need to generate passwords I suggest using either pwgen or openssl rand.

    In this case however you are encrypting the password using your rsa public key. Why not skip some steps and just use gpg to encrypt the file with your gpg public key? You won't need to generate a password at all.

  • ReyRey Member
    edited April 2016

    @Abdussamad said:

    Rey said: I wrote few times ago a little backup script in bash for my website.

    If you need to generate passwords I suggest using either pwgen or openssl rand.

    In this case however you are encrypting the password using your rsa public key. Why not skip some steps and just use gpg to encrypt the file with your gpg public key? You won't need to generate a password at all.

    Because with gpg I had some issue (decrypt from windows, probably my mistakes) so I tried openssl and It's works.

  • @Rey said:
    I wrote few times ago a little backup script in bash for my website.. It can be used with a cronjob, it backup files and mysql, encrypt and send all to dropbox with another bash script. Hope it will help you. I'm not a programmer so if anyone more expert than me want to comment :)

    Need: https://github.com/andreafabrizi/Dropbox-Uploader

    edit: Unfortunately the code with copy&paste is a shit..

    Thanks but I am on shared hosting so I sadly don't have access to bash or SSH.

  • That's a pretty crappy shared hosting service that doesn't offer ssh access to your account.

  • rsync and key pair ssh connection?

  • ReyRey Member

    @TehEnforce said:

    @Rey said:
    I wrote few times ago a little backup script in bash for my website.. It can be used with a cronjob, it backup files and mysql, encrypt and send all to dropbox with another bash script. Hope it will help you. I'm not a programmer so if anyone more expert than me want to comment :)

    Need: https://github.com/andreafabrizi/Dropbox-Uploader

    edit: Unfortunately the code with copy&paste is a shit..

    Thanks but I am on shared hosting so I sadly don't have access to bash or SSH.

    I'm on shared hosting with directadmin and everything works well. Check if your provider accept outgoing traffic.

  • @jcaleb said:
    rsync and key pair ssh connection?

    Sadly no SSH. Shared hosting.

    @Rey

    I am on DirectAdmin too. What do you mean with outgoing traffic?
    No SSH support. My provider don't even support Let's Encrypt yet :///

  • ReyRey Member

    @TehEnforce said:

    @jcaleb said:
    rsync and key pair ssh connection?

    Sadly no SSH. Shared hosting.

    @Rey

    I am on DirectAdmin too. What do you mean with outgoing traffic?
    No SSH support. My provider don't even support Let's Encrypt yet :///

    First of all download https://github.com/andreafabrizi/Dropbox-Uploader/archive/master.zip
    Then in other machine with ssh make the setup.
    Now you have the file .dropbox_uploader like this:

    APPKEY:xxx
    APPSECRET:xxx
    ACCESS_LEVEL:sandbox
    OAUTH_ACCESS_TOKEN:xxx
    OAUTH_ACCESS_TOKEN_SECRET:xxx

    Upload in your shared hosting the file.
    Give the execution permission to the script dropbox_uploader.sh
    Create a testfile.txt
    Create a bash script with inside the code to upload your testfile.
    Create the cronjob in your directadmin panel.

    If your provider accept outgoing traffic and have curl enabled everything may works well :)

  • Even if you don't have SSH access you can still run Linux bash cronjobs from cPanel, either log the output to a file or check the crontab email for errors. Make sure you chmod the file to 770 or something sensible, your file has the proper shebang, and you include the full path to the script in cPanel cron jobs bit.

    It might be worth asking your host for their advice before you start this, they might have some other options or ideas.

  • SadySady Member

    @linuxthefish said:
    Even if you don't have SSH access you can still run Linux bash cronjobs from cPanel, either log the output to a file or check the crontab email for errors. Make sure you chmod the file to 770 or something sensible, your file has the proper shebang, and you include the full path to the script in cPanel cron jobs bit.

    It might be worth asking your host for their advice before you start this, they might have some other options or ideas.

    Didn't know of this, going to set it up on my MXRoute accounts tomorrow.

  • @Rey said:

    @TehEnforce said:

    @jcaleb said:
    rsync and key pair ssh connection?

    Sadly no SSH. Shared hosting.

    @Rey

    I am on DirectAdmin too. What do you mean with outgoing traffic?
    No SSH support. My provider don't even support Let's Encrypt yet :///

    First of all download https://github.com/andreafabrizi/Dropbox-Uploader/archive/master.zip
    Then in other machine with ssh make the setup.
    Now you have the file .dropbox_uploader like this:

    APPKEY:xxx
    APPSECRET:xxx
    ACCESS_LEVEL:sandbox
    OAUTH_ACCESS_TOKEN:xxx
    OAUTH_ACCESS_TOKEN_SECRET:xxx

    Upload in your shared hosting the file.
    Give the execution permission to the script dropbox_uploader.sh
    Create a testfile.txt
    Create a bash script with inside the code to upload your testfile.
    Create the cronjob in your directadmin panel.

    If your provider accept outgoing traffic and have curl enabled everything may works well :)

    Thanks! Will try that.

    @linuxthefish
    Thanks! Going to ask my host and try that one out too.

Sign In or Register to comment.