Skip to content

Instantly share code, notes, and snippets.

View danlake's full-sized avatar

Dan Lake danlake

View GitHub Profile
@danlake
danlake / filebakup.sh
Created September 16, 2016 14:00
File backup bash script to be run by cron
#!/bin/sh
now="$(date +'%d_%m_%Y_%H_%M_%S')"
filename="filebak_$now".gz
folder="/path/to/bak"
fullpath="$folder/$filename"
log="$folder/"backup_log_"$(date +'%Y_%m')".txt
files="/source/file/path"
echo "file backup started at $(date +'%d-%m-%Y %H:%M:%S')" >> "$log"
tar -cpzf $fullpath $files
echo "file backup finished at $(date +'%d-%m-%Y %H:%M:%S')" >> "$log"
@danlake
danlake / mysqldbbackup.sh
Created September 15, 2016 10:37
MySQL backup bash script to be run by cron
#!/bin/sh
now="$(date +'%d_%m_%Y_%H_%M_%S')"
filename="dbbak_$now".gz
folder="/path/to/bak"
fullpath="$folder/$filename"
log="$folder/"backup_log_"$(date +'%Y_%m')".txt
echo "mysqldump started at $(date +'%d-%m-%Y %H:%M:%S')" >> "$log"
mysqldump --user=mydbuser --password=mypass --default-character-set=utf8 mydatabase | gzip > "$fullpath"
echo "mysqldump finished at $(date +'%d-%m-%Y %H:%M:%S')" >> "$log"
echo "*****************" >> "$log"
@danlake
danlake / Plugin_NamedController.php
Last active June 15, 2016 15:11
Craft CMS Plugin Controller example accepting AJAX file upload to S3 bucket
<?php
/**
* Cotroller action to accept AJAX file upload with S3 bucket set up in Craft Assets
*
* Based on AJAX file upload example by Connor Smith [https://gist.github.com/sathoro] - https://gist.github.com/sathoro/8178981
* Requires AWS PHP SDK installed and included - http://docs.aws.amazon.com/aws-sdk-php/v3/guide/getting-started/installation.html
* This example used Composer and autoloaded in the init() method to the main plugin's class file
*
**/