Skip to content

Commit

Permalink
Fixed dist and readme
Browse files Browse the repository at this point in the history
  • Loading branch information
idachev committed Jan 10, 2018
1 parent 5a1069c commit 9256960
Show file tree
Hide file tree
Showing 8 changed files with 66 additions and 48 deletions.
27 changes: 16 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
# Auto Home Backup

Auto Home Backup script to Dropbox using bash and [Dropbox SDK PHP](https://github.com/dropbox/dropbox-sdk-php). Ideal for full web sites backup from cPanel.
Auto Home Backup script to Dropbox using bash and [Dropbox v2 SDK PHP](https://github.com/kunalvarma05/dropbox-php-sdk)

The best solution for full web sites backup from cPanel.

License: [GNU](LICENSE)

[Latest Release v1.0.6 - Direct Download](https://github.com/idachev/autohomebackup/releases/download/v1.0.6/autohomebackup_v1.0.6_20170831_062543.tar.gz)
[Latest Release v2.0.1 - Direct Download](https://github.com/idachev/autohomebackup/releases/download/v2.0.1/autohomebackup_v2.0.1_20180110_000000.tar.gz)

[All Releases](https://github.com/idachev/autohomebackup/releases)

Expand All @@ -28,15 +30,13 @@ If you like my work and it save you a valuable time and effort, please buy me a
In order to use the script you need to do the following:
1. Have a Dropbox account
2. Create a Dropbox App Folder - you can create such application folder from your Dropbox account here [Dropbox Apps](https://www.dropbox.com/developers/apps).
3. Make a Dropbox SDK PHP authentication file - steps are listed here [Dropbox SDK PHP - Get a Dropbox API key](https://github.com/dropbox/dropbox-sdk-php#get-a-dropbox-api-key).

These steps are done only once and you should do them from your local Linux box.
3. Make a Dropbox API token - steps are listed here [Generate Access Token](https://blogs.dropbox.com/developers/2014/05/generate-an-access-token-for-your-own-account/).

It is preferred to use a Dropbox App authentication, check the [Dropbox SDK PHP - Get a Dropbox API key](https://github.com/dropbox/dropbox-sdk-php#get-a-dropbox-api-key) documentation.
It is preferred to use a Dropbox App authentication.

## Setup

Please make your own config file for better managment.
Please make your own config file for better management.
You could see detailed description of the config options in the script itself.

Check examples below.
Expand Down Expand Up @@ -98,12 +98,18 @@ Email address to send mail to.
DROPBOX_UPLOADER_PHP="dropbox_uploader_php.sh"
```
`dropbox_uploader_php.sh` script location provided along with this script


```
DROPBOX_UPLOADER_PHP_AUTH=".dropbox_uploader_php.auth"
```
`.dropbox_uploader_php.auth` token for more info how to create a auth file check [Dropbox SDK PHP - Get a Dropbox API key](https://github.com/dropbox/dropbox-sdk-php#get-a-dropbox-api-key) documentation
`.dropbox_uploader_php.auth` holding a Dropbox API token.

The format of the file should be:
```
{
"access_token": "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"
}
```

```
MAIL_CONTENT="log"
Expand Down Expand Up @@ -134,7 +140,6 @@ Examples below are assuming that you uploaded the script release files to
`/home/<cpaneluser>/bin`

Also the script will look by default for `/home/<cpaneluser>/bin/.dropbox_uploader_php.auth`.
This file will be generated from [Dropbox SDK PHP - Get a Dropbox API key](https://github.com/dropbox/dropbox-sdk-php#get-a-dropbox-api-key) authentication setup.

### Cron Jobs Example

Expand Down Expand Up @@ -222,7 +227,7 @@ MAIL_ADDR="admin@site-a.com"

:zap: The paths in `EXCLUDE` option must be relative to `BASE_DIR` or `BASE_DIR/DIRS_TO_BACKUP`

:zap: The `Dropbox-App-Name` will be the one that you configured from [Dropbox SDK PHP - Get a Dropbox API key](https://github.com/dropbox/dropbox-sdk-php#get-a-dropbox-api-key) authentication setup.
:zap: The `Dropbox-App-Name` will be the one for which you generated the access token.

:zap: The `/home/<cpaneluser>/mysql-backups` from examples above is a directory where [Auto MySQL Backup](https://sourceforge.net/projects/automysqlbackup/)
is setup to regularly backup MySQL database files. Its cron job should be placed to be executed before the cron job for Auto Home Backup.
Expand Down
1 change: 0 additions & 1 deletion build/dropbox-sdk-php-version.txt

This file was deleted.

49 changes: 18 additions & 31 deletions build/gen_dist.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,52 +22,39 @@
BASEDIR=$(readlink -f $0)
BASEDIR=$(dirname ${BASEDIR})

DROPBOX_SDK_PHP_VERSION=`cat ${BASEDIR}/dropbox-sdk-php-version.txt`
DROPBOX_SDK_PHP="https://codeload.github.com/dropbox/dropbox-sdk-php/zip/v${DROPBOX_SDK_PHP_VERSION}"

echo -e "Downloading Dropbox SDK PHP\n${DROPBOX_SDK_PHP}"
TMP_DIR=`mktemp -d`
DST_ZIP="${TMP_DIR}/phpsdk.zip"
curl -s -S -o "${DST_ZIP}" ${DROPBOX_SDK_PHP}
if [ $? -ne 0 ];then
echo "\nDropbox SDK PHP download failed!"
exit 1
fi

TMP_DIR_ZIP=`mktemp -d`
unzip -qq "${DST_ZIP}" -d "${TMP_DIR_ZIP}"
if [ $? -ne 0 ];then
echo -e "\nFailed to extract\n\t${DST_ZIP}\nto\n\t${TMP_DIR_ZIP}"
exit 1
fi

GIT_HASH=$(git rev-parse --short HEAD)

cd ${BASEDIR}/..
composer install
cd ${BASEDIR}

BUILD_VERSION=`cat ${BASEDIR}/version.txt`
BUILD_YEAR=$(date +"%Y")
BUILD_DATE=$(date +"%Y%m%d")
BUILD_DATE_TIME=$(date +"%Y%m%d_%H%M%S")
BUILD_NAME="autohomebackup_v${BUILD_VERSION}_${BUILD_DATE_TIME}"

DIST_DIR="${BASEDIR}/dist"
BUILD_DIR="${DIST_DIR}/${BUILD_NAME}"
DROPBOX_SDK_PHP_DIR="${BUILD_DIR}/dropbox-sdk-php"
mkdir -p ${BUILD_DIR}
mkdir -p ${DROPBOX_SDK_PHP_DIR}

cp -a ${BASEDIR}/../src/*sh ${BUILD_DIR}
cp -a ${BASEDIR}/../src/*php ${BUILD_DIR}
cp -a ${BASEDIR}/../src/template.dropbox_uploader_php.auth ${BUILD_DIR}/.dropbox_uploader_php.auth
cp -a ${BASEDIR}/../LICENSE ${BUILD_DIR}
cp -a ${BASEDIR}/../README.md ${BUILD_DIR}
cp -a "${TMP_DIR_ZIP}/dropbox-sdk-php-${DROPBOX_SDK_PHP_VERSION}/lib" ${DROPBOX_SDK_PHP_DIR}
cp -a "${TMP_DIR_ZIP}/dropbox-sdk-php-${DROPBOX_SDK_PHP_VERSION}/examples" ${DROPBOX_SDK_PHP_DIR}
cp -a "${TMP_DIR_ZIP}/dropbox-sdk-php-${DROPBOX_SDK_PHP_VERSION}/License.txt" ${DROPBOX_SDK_PHP_DIR}
touch ${DROPBOX_SDK_PHP_DIR}/v${DROPBOX_SDK_PHP_VERSION}
cp -a ${BASEDIR}/../vendor ${BUILD_DIR}

function replace_versions {
sed -i "s/#BUILD_VERSION#/${BUILD_VERSION}/g" ${1}
sed -i "s/#GIT_HASH#/${GIT_HASH}/g" ${1}
sed -i "s/#BUILD_DATE#/${BUILD_DATE}/g" ${1}
sed -i "s/#BUILD_YEAR#/${BUILD_YEAR}/g" ${1}
}

sed -i "s/#BUILD_VERSION#/${BUILD_VERSION}/g" ${BUILD_DIR}/autohomebackup.sh
sed -i "s/#BUILD_VERSION#/${BUILD_VERSION}/g" ${BUILD_DIR}/dropbox_uploader_php.sh
sed -i "s/#GIT_HASH#/${GIT_HASH}/g" ${BUILD_DIR}/autohomebackup.sh
sed -i "s/#GIT_HASH#/${GIT_HASH}/g" ${BUILD_DIR}/dropbox_uploader_php.sh
sed -i "s/#BUILD_DATE#/${BUILD_DATE}/g" ${BUILD_DIR}/autohomebackup.sh
sed -i "s/#BUILD_DATE#/${BUILD_DATE}/g" ${BUILD_DIR}/dropbox_uploader_php.sh
replace_versions ${BUILD_DIR}/autohomebackup.sh
replace_versions ${BUILD_DIR}/dropbox_uploader_php.sh
replace_versions ${BUILD_DIR}/dropbox_v2_uploader.php

BUILD_FILE=${DIST_DIR}/${BUILD_NAME}.tar.gz
tar czf "${BUILD_FILE}" -C ${DIST_DIR} ${BUILD_NAME}
Expand Down
2 changes: 1 addition & 1 deletion build/version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.0.6
2.0.1
6 changes: 4 additions & 2 deletions src/autohomebackup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Auto Home Backup Script
# v#BUILD_VERSION# #BUILD_DATE# #GIT_HASH#
# https://github.com/idachev/autohomebackup
# Copyright (c) 2016 Ivan Dachev
# Copyright (c) #BUILD_YEAR# Ivan Dachev
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -118,9 +118,11 @@ MAX_ATT_SIZE="4000"
# Change Log
#=====================================================================
#
# VER 2.0.1 - (2018-01-10)
# - Switched to use a new PHP DropBox SDK that supports API v2
# VER 1.0.6 - (2017-08-31)
# - Always remove the backup file even on error otherwise the disk
# is exausted too quickly
# is exhausted too quickly
# VER 1.0.5 - (2016-04-16)
# - Changed to store with year-month sub dir on destination backup
# VER 1.0.4 - (2016-03-07)
Expand Down
4 changes: 2 additions & 2 deletions src/dropbox_uploader_php.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Auto Home Backup Dropbox Uploader PHP Script
# v#BUILD_VERSION# #BUILD_DATE# #GIT_HASH#
# https://github.com/idachev/autohomebackup
# Copyright (c) 2016 Ivan Dachev
# Copyright (c) #BUILD_YEAR# Ivan Dachev
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
Expand All @@ -19,7 +19,7 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# It uses the https://github.com/dropbox/dropbox-sdk-php
# It uses the https://github.com/kunalvarma05/dropbox-php-sdk
#
#=====================================================================
#set -x
Expand Down
22 changes: 22 additions & 0 deletions src/dropbox_v2_uploader.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,26 @@
<?php
/**
* Auto Home Backup Dropbox Uploader PHP Script
* v#BUILD_VERSION# #BUILD_DATE# #GIT_HASH#
* https://github.com/idachev/autohomebackup
* Copyright (c) #BUILD_YEAR# Ivan Dachev
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* It uses the https://github.com/kunalvarma05/dropbox-php-sdk
*/

require __DIR__ . '/vendor/autoload.php';

Expand Down
3 changes: 3 additions & 0 deletions src/template.dropbox_uploader_php.auth
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"access_token": "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"
}

0 comments on commit 9256960

Please sign in to comment.