Allow to backup sites (databases + files) easily using a YML configuration file.
# Get the application
wget https://devgiants.github.io/websites-backup/downloads/websites-backup-1.3.2.phar
# Move it in command folder
mv websites-backup-1.3.2.phar /usr/bin/backup
# Make it executable
chmod u+x /usr/bin/backup
You can use it to backup files + database (MySQL only so far). You can provide as much sites as you want, and several storage medias as well.
backup save --file=config.yml
Below a full YAML example, commented :
configuration:
# this is the max backup number you accept to keep on each storage media provided below
remanence: 5
# this is the log path you want. Default to /tmp/websites-backup-logs/
log_folder: "/path/to/log/folder"
sites:
# Add as much site section as you want. The key here is free, and will be used on retrieve command
site-1:
# Set of commands you want to see run BEFORE backup. ATTENTION : the commands are executed without any verifications
pre_save_commands:
- "mkdir /tmp/pre_test_command"
database:
server: localhost
user: root
password: "password"
name: database_name
files:
# root dir to refer to
root_dir: "/var/www/html/my-site/"
# Folder list to include (root dir based)
include:
- "my-folder/to-include"
# Files/Folder list to exclude (root dir based)
exclude:
- "my-folder/to-exclude"
- "my-folder2/my-specific-file.file"
# Specific storages among those listed below. Optionnal : if not provided, backup will use all storages available
backup_storages:
- dropbox_test
post_save_commands:
- "mkdir /tmp/post_test_command"
site-2:
...
backup_storages:
# key here is free as well. Same as above, will be used in retrieve command to specify storage media to retrieve backup from
ftp1:
# So far, FTP only
type: FTP
# For opening connection with SSL. Set it to false or don't mention it for regular FTP connection
ssl: true
# Passive mode
passive: true
server: ftp.server.com
user: ftp_user
password: "password"
# Remote root dir
root_dir: "/sites"
dropbox_test:
type: Dropbox
# Obtain those 3 params from you dropbox account page, app section.
client_id: clientid
client_secret: clientsecret
access_token: accesstoken
root_dir: "/"
The retrieve method will allow you to get one backup back :
backup retrieve --file=config.yml
The command will ask you :
- Which storage to retrieve backup from (among the storages defined in config file, and if you didn'tvmention it already with the -s option (
backup retrieve -f=config.yml -s=ftp1
)) - Which site you want to retrieve backup from
- Backup timestamp (among the availables ones)
Then it will put the files (basically tar + sql files) in /tmp folder.
The application is modular, each storage is created a Devgiants/Storage/Storage class instance.
More to come : SSH Storage, Local filesystem Storage, backup executed as user, tests...
backup self-update
will automatically update the PHAR archive.
The app comes with an Docker stack which configure 3 images :
- PHP FPM (including Composer and Box for PHAR packaging)
- MySQL
- PHPMyAdmin
As it's a pure console app, two last are just here on dev testing purpose because it allow app to connect to MySQL.
Just update .env
file with you data. Then you can execute init.sh
.
Just do a docker-compose up -d
like any other Docker stack.
Logs are quite verbose. 2 distincts channels are created :
- the
main
one for global events - one channel per site on each command (backup and retrieve)
Both are implemented using the RotatingFileHandler
from Monolog.
This bash script goal is to ease tedious PHAR packaging process for a open-source app published on Github. This script is very specific to following case :
- Open-source project hosted on Github
- Use Box for create package
- Use Kherge version (abandoned) to handle version number. TODO is to switch to maintained project ASAP
- Use a manifest system to publish phar archive to gh-pages. You can have live example on applications I created such as livebox or websites-backup
Just make sur your local master
branch is up-to-date, with README updated with good version number (the one you publish). Then:
./make-phar -n appname -v 1.2.3
This will do, in order :
- Create local tag with version passed as argument
- Push
master
branch to remote repo - Push tags to remote repo
- Build PHAR using
box
- Move generated PHAR to
/tmp
- Checkout to
gh-pages
- Move generated archive from
/tmp
todownloads/{appname}-{version}.phar
- Create matching manifest file
- Push everything to
gh-page
remote branch. - Switch back to
master