Bash Aliases

We encourage users to post events happening in the community to the community events group on https://www.drupal.org.
rgchi's picture

I can't imagine administering drupal without drush. I've set up some aliases in my bash profile. I've become so dependent on these, that I synchronize my alias.sh file through bitbucket. For example, the function drupre will put the site in offline mode, run cron, clear cache, and then put the site back in online mode. The other is drubackup which will save the file structure and database dump to a date based file structure.

Does anyone have any other alias commands to speed up work flow?

# drupal and drush
alias drupoff='drush vset site_offline 1'
alias drupon='drush cron && drush vset site_offline 0'
alias drupre='drupoff -y && drush cron &&  drush cc all && drupon -y'
alias drubase='cd /var/www/html'
alias drulog='drush watchdog-show'

function drubackup {
    export sourcefolder='/var/www/html'
    export backupfolder="~/backup/drupal/$(date +%Y/%m/%d/%H/%M)/"
   
    # temporariliy go to drupal base folder
    pushd $sourcefolder
    drupoff -y

    # Create backup folder, recursive copy, and save db dump
    mkdir -p $backupfolder
    sudo cp -vr $sourcefolder $backupfolder
    drush sql-dump > $backupfolder/commons.sql

    # activate site, go back to orginial folder
    drupon -y
    popd
}
# fix cron job
function drufixcron {
  drush sqlq 'DELETE FROM variable WHERE name="cron_semaphore"'
  drush sqlq 'DELETE FROM variable WHERE name = "cron_last"'
}


# LAMP
alias resetlamp='sudo /etc/init.d/httpd restart && sudo /etc/init.d/mysqld restart'
alias taillogs='sudo tail -f /var/log/httpd/error_log /var/log/httpd/access_log'

Comments

toddgee's picture

see toddgee.com [slash] drupalScripts (my attempt at circumventing the spam filter)

or svn.toddgee.com [slash] drupalScripts to see the scripts themselves.

I have a script that wraps 'drush dl' that I find very helpful, a script for site duplication (dupe a script from one domain/db to another domain/db), reporting, database queries, etc.

Initially, they weren't written on top of drush (used CVS, and then Git) but I gave up and now leverage drush for installations and updates.