Terminal Commands

mv /path/subfolder/{.,}* /path/ # copy files securely via ssh [remote -> local] (-r for recursive is applicable, -P for port) scp -i test.pem ubuntu@hostname:/remote/location/path /destination/path # copy files securely [local -> remote] scp -i test.pem /destination/path ubuntu@hostname:/remote/location/path   # TAR Compress tar -czvf /tmp/destination.tar.gz -C [directory] [context_directory] Example: tar -czvf /tmp/destination.tar.gz -C /tmp/where_to_compress . ### Decompress / Extract tar -xzvf...

Backing up MySQL database

Backup using innobackupex This script backups your database and uploads it to Amazon S3: #!/bin/bash timestamp=`date “+%Y-%m-%d_%H-%M-%S”` innobackupex –user=[username] –password=[password] –parallel=3 –safe-slave-backup –slave-info –no-timestamp /data/backup/${timestamp}_slave innobackupex –user=[username] –password=[password] –apply-log /data/backup/${timestamp}_slave/ tar czf /data/backup/${timestamp}_slave.tgz /data/backup/${timestamp}_slave /usr/local/bin/aws –region [region] s3 cp /data/backup/${timestamp}_slave.tgz s3://[bucket]/[backup-path]/`date “+%Y”`/`date “+%m”`/`date “+%d”`/ rm -rf /data/backup/${timestamp}_slave rm -f /data/backup/${timestamp}_slave.tgz You can easily write this script in backup.sh and schedule a cronjob...

htaccess : how to redirect non-www url to www

Place the following configuration in your .htaccess file: RewriteEngine On RewriteCond %{HTTP_HOST} !^www\. RewriteCond %{HTTP_HOST} !=localhost RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L] This line is placed to make sure that redirection does not occur on your localhost during the development process. You can remove this line if you want to place the .htaccess configuration directly on your production server. Otherwise you can...

Quickbooks – PHP integration

Integration:  PHP and Quickbooks using v3-php-sdk-2.0.5 This was a bit of headache. In this article I explain how to configure your quickbooks php sdk, issues faced, fixes until successful integration. Some useful references to accomplish php / quickbook integration using the php sdk. – download php sdk http://bit.ly/IppPhpSdkV3 – PHP SDK for QuickBooks V3 documentation and getting started https://developer.intuit.com/docs/0100_accounting/0500_developer_kits/0210_ipp_php_sdk_for_quickbooks_v3 *** Trying...