Backing up Mysql data

Permalink 09/28/07 09:00:00 am, Categories: GNUnix  

Here's a simple script that can be used in a cron job on Linux/Unix server.


mysqldump -u [mysqluser] -p [mysqlpass] --all-databases | gzip -9 > `date +%y-%m-%d_%H%M`export.gz

This kind of command is obvious to anyone who's used Linux with any frequency, but can be cryptic to a newbie.

Here are some notes, in case you are interested:

  • mysqldump - a utility that will output the current state of your mysql server into a text file
  • -u [mysqluser] -p [mysqlpass] - allows this command to run without having to prompt the user for a password (essential if we're going to run this as a scheduled event
  • --all-databases - an option for the mysqldump command that instructs it to dump the data for all the databases in the server
  • | - makes the output for the first command be the input for the second command (one of the most powerful features of the shell)
  • gzip - a utility that will compress text (similar to zip)
  • -9 - tells gzip to make the output as small as possible (takes more processor time, but results in smaller file size)
  • > - directs the output of the gzip command into a file (overwriting if the file exists)
  • `date +%y-%m-%d_%H%M`export.gz - tells the command line to run the date command with the specified format (year-month-date_hourminute). Used to create a semi-unique file name

Plogger a pretty good start for an image gallery

Permalink 09/19/07 09:00:00 am, Categories: Development, Misc., GNUnix  

I have recently installed Plogger, an open-source, php app that creates an image gallery. I am looking for software very close to what this one offers, but find this one a little lacking. I think I may submit some patches, however, because overall, the product is pretty good.

Here's what I wish it had

  • Don't copy the images into the installation directory, serve them from my storage location
  • Slide show should be flash based, like Flickr, not a page refreshed via META refresh settings
  • Batch image manipulation through the site would be good (eg. rotating images
  • Any image manipulation through the site would be good

Awesome features

  • Autogenerates thumbnails
  • Utilizes AJAX to reduce browser load times
  • Intuitive importing
  • Skinnable (presumably)

Top 10 Gnu tools

Permalink 01/12/07 09:59:36 am, Categories: GNUnix  

Here's a list of my favorite Unix tools from the Free Software Foundation.

  1. gzip - The quintessential compression utility. This has to be one of the most used binaries in the world.
  2. Bash - The beginner's shell. Still one of the easiest shells to use. Yeah, yeah, ksh is great.
  3. Patch diffutils - Larry Wall's other great contribution, patch, is a key component to distributed development. Patch relies on the mathematical help of diff, so I include it here as well.
  4. grep - Ok, forget what I said about gzip. Grep has to be the most commonly used utility. I would use Perl a lot more if grep didn't exist.
  5. findutils specifically, xargs - The tool that changed the way that I think about the command line.
  6. Screen - Takes some time to get used to key commands, but well worth the effort. Get a multiple windowed terminal.
  7. Wget - How else are you going to download that whole website? IE? Fuffycuck!
  8. gcc gdb - Probably the most successful GNU tools. Maybe the most important ones as well.
  9. Gimp - Stop using that unlicensed version of Photoshop and make the jump to Gimp. Unless you're a real pro, you can probably get everything you need out of the Gimp... with a little effort.
  10. GNU GRUB hurd - I'm still waiting to see if this takes off. The FSF missed their window by about 14 years, but the microkernel/monolithic debate is back in full gear. I made it number one because I believe in the foundations valiant efforts, but when a google search for hurd reveals the GNU project is not number 1, I kind of lose a little faith.

Brain dead shell scripts

Permalink 12/06/06 02:50:51 pm, Categories: GNUnix  

Here are some Gnu Linux/Unix commands that I run so often, I've pulled them into some simple shell scripts.

  • Search and Destroy
    This script will kill any processes that match the argued parameter

    #!/bin/sh
    if [ $# -lt 1 ]; then
    echo 1>&2 Usage: $0 [search string]
    echo 1>&2 Search and Destroy will take a command argument
    echo 1>&2 and kill all processes that
    echo 1>&2 match the search string in a 'ps -aef' command
    echo 1>&2 example: $0 httpd - kills all apache processes
    exit 1
    fi
    ps -aef | grep $1 | grep -v grep | awk '{print $2}' | xargs kill -9

  • Fake CVS Update
    Find out what would be performed by a cvs update
    Optionally takes an arguement to allow you to pass other cvs Flags (like -A for sticky tags)

    #!/usr/bin/sh
    cvs -n update $1 2>&1 | grep -v ^cvs

  • Escape to Paradise
    Will convert any input from x to "x"

    #!/bin/sh
    sed -e 's:\(.*\):"\1":g'

Active Directory Authentication for Apache

Permalink 12/04/06 11:20:58 am, Categories: Development, GNUnix  

I'm so excited! I was able to get my Apache web server instances to use Microsoft's Active Directory as an LDAP server for authentication and role definitions. It was surprisingly easy. Here's how I did it for both 1.3 and 2.x series Apache servers. Incidentally, I'm using Debian Linux, so I'm not going to go through the details on building those modules.

Apache 1.3
Install the mod_ldap and auth_ldap modules into your Apache server. On Debian, this was as easy as this..

  1. I checked for the necessary modules using APT

    > apt-cache search --names-only ldap | grep apache
    libapache-auth-ldap - LDAP authentication module for Apache
    libapache-mod-ldap - Apache authentication via LDAP directory
    ...

  2. Install the necessary modules

    > apt-get install libapache_mod_auth_ldap
    > apt-get install libapache_mod_ldap

  3. Modify the http.conf or module.conf files to include the modules

    LoadModule ldap_module /usr/lib/apache/1.3/mod_ldap.so
    LoadModule auth_ldap_module /usr/lib/apache/1.3/auth_ldap.so

  4. Configure your LDAP bindings for the user and the groups (see here for a discussion on configuring mod_auth_ldap)

    <directory "/">
    ...
    AuthType Basic
    AuthName "Active Directory Login"
    AuthLDAPEnabled On
    AuthLDAPURL ldap://[servername]:389/dc=xxxxxx,dc=com?sAMAccountName
    AuthLDAPBindDN "cn=[ad user name],ou=[organizational units]...,dc=xxxxxx,dc=com"
    AuthLDAPBindPassword "[your password here]"
    require valid-user
    require group "ou=[required groups]"
    ...
    </directory>

Apache 2.x
Apache2 is much the same as Apache 1.3, only one is able to take advantage of the easier server layout. I'll only include notes on changes from the 1.3 install above.

  1. Same as above (although you may want to see if there are apach2 specific ldap modules available when you install. There weren't when I wrote this).
  2. Same as above
  3. With Apache2, you will simply need to sym-link the modules to load in the mods-enabled from the mods available. I ended up with

    /etc/apache2$ ls -al mods-enabled/
    lrwxrwxrwx 1 xxxx yyyy 42 Nov 30 15:55 auth_ldap.load -> ...
    lrwxrwxrwx 1 xxxx yyyy 41 Nov 29 09:58 auth_pam.load -> ...
    lrwxrwxrwx 1 xxxx yyyy 36 Nov 21 15:40 cgi.load -> ...
    lrwxrwxrwx 1 xxxx yyyy 37 Nov 21 15:40 php5.conf -> ...
    lrwxrwxrwx 1 xxxx yyyy 37 Nov 21 15:40 php5.load -> ...

  4. Same config as above, except I was able to configure this under by instance config instead of httpd.conf (which is an Apache2 feature I've really grown to love).

At the end, I had LDAP authentication against my Active Directory server!

:: Next Page >>

The Farrellel Universe

A weblog focusing on software development, computer science, mathematics, music, and probably lacking focus.

September 2010
Sun Mon Tue Wed Thu Fri Sat
 << <   > >>
      1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30    

Search

Categories

XML Feeds

What is this?

powered by b2evolution free blog software