How to backup to Amazon S3

Posted by: on Jan 18, 2012 in News, Support, Web Development | No Comments

Need to backup your Linux server files and databases to Amazon S3? Here is a great tool – http://s3tools.org/download

Follow the install instructions.

Once you set up your S3 bucket, you can use this bash script to copy files to the S3 bucket:


#!/bin/sh
#
## Lanexa.net - file name = BACKUP_s3.sh
## backup script to push archive files to Amazon S3 bucket
## 2012-01-04
#
# define where your backup files are stored locally on your server
FILEDIR=/BACKUP/files/
DBDIR=/BACKUP/mysql/
#
cd $FILEDIR
#
# use s3cmd to upload files to S3 instance
s3cmd put FILENAME s3://BUCKET-NAME/
#
cd $DBDIR
s3cmd put DATABASES s3://BUCKET-NAME/
#
# email a note to yourself that backup is complete
mail -s "backup files and databases copied to S3" youremail@address.com

Site Migration from Server1 to Server2: WordPress and Drupal friendly

Posted by: on Oct 24, 2011 in News, Support | No Comments

This post was borne out of our mass migration to Rackspace. Naturally, it gets into some advanced, hairy stuff. However, when fully dialed in, this method can take less than 5 minutes, even for large WordPress or Drupal sites. In order to complete these tasks, you will need privileged shell access to both servers (including mysql access), you will need to have rsync installed and configured, and you will need DNS access to the destination server (server2).
* Note: The following steps contain some powerful commands. Please be careful! And don’t execute any command if, after reading the details, you are still unsure what will happen.

1. Export your MySQL Database using mysqldump. This is the only step that must be done while logged into server1.
More Details

1-2. Edit db_backup.sql. This only needs to be done if you plan to create a fully-functional development version of your site. Open db_backup.sql in your editor of choice. Find & Replace all old URLs (http://old_site.com) to the new URLs (http://dev_site.server2.com). Rename the .sql file & save it.

*Remaining steps will be done from server2.

2. Create a DNS entry for the site’s new home.

3. Establish the document root for your site’s new home – i.e. create the new site directory.

user@server2:~$ mkdir /path/to/new_site_dir

4. Use rsync to migrate your site directory. Our example will transfer files from old_site_dir on server1 to new_site_dir on server2.

user@server2:/path/to/new_site_dir$ rsync -avz user@server1:/path/to/old_site_dir/ .

More Details

4-2. Check owner/group of new directory. Be sure it is consistent with working sites.

5. Create MySQL database, database user, database password, and privileges.

mysql> create database db_name; 
mysql> create user db_user;
mysql> grant all on db_name.* to 'db_user'@'localhost' identified by 'db_password';

More Details

6. Upload the db_backup.sql. This will be imported into your newly created database (from previous step).

user@server2:~$ mysql -u mysql_user -p db_name < db_backup.sql

More Details

7. Update your site’s database settings. For WordPress, update wp-config.php with your info from step 5. For Drupal, update settings.php with your info from step 5.
More Details

8. Add the VirtualHost record to your apache2 configuration file.
8-2. Restart Apache once the new VirtualHost record has been added.
More Details

How to import your .sql into a MySQL database

Posted by: on Oct 23, 2011 in News, Support, Web Development | No Comments

How to import your db_backup.sql into an empty database:

user@server:~$ mysql -u mysql_user -p db_name < /path/to/db_backup.sql

How to export your MySQL database using mysqldump

Posted by: on Oct 18, 2011 in News, Support, Web Development | No Comments

Use your command line to backup your mysql database by exporting it to an .sql file. All you need to complete this task is shell access & a mysql account.

A major use for this command is to easily migrate your sites from one server to another. Since this is often part of a larger process, I like to decide ahead of time which directory will contain this file. So I’ll start by navigating to my desired directory and scoping it out:

user@server:~$ cd /path/to/dir/; ls -al

Now that you’re sure about using this directory. Here is the basic mysqldump command:

user@server:/path/to/dir$ mysqldump db_name > db_backup.sql

But, depending on your level of access, you may need to modify it:

user@server:/path/to/dir$ mysqldump -u mysql_user -p db_name > db_backup.sql
Enter password:

After entering your mysql password, a file called db_backup.sql will be created in the default location, which is your current directory (three cheers for planning ahead!).
Of course, we could have just as easily added a location statement within the command:

user@server:~$ mysqldump -u mysql_user -p db_name > /path/to/dir/db_backup.sql

But, you’re going to want to cd there anyways, just to verify that everything’s in order :-)

Be sure to browse our related posts describing how to get migrate files from one server to another, and how to import an .sql file into an empty MySQL databse.

wget the latest WordPress installed – pronto!

Posted by: on Sep 23, 2011 in News, Support, Web Development | No Comments

It’s so flippin’ fast! Forget about FTP-ing…

Step 1: wget it.

user@server:~$ wget http://wordpress.org/latest.tar.gz

This command will place the file in your current directory. You may plan on unpacking & installing in multiple directories, so you may want to cd to the parent directory of those locations. Plus, if you choose this method to get the next latest version, you can wget it in the same directory and override the previous version.

Step 2: Copy it to your desired directory

user@server:~$ cp latest.tar.gz /path/to/your/directory;

Step 3: Go to that directory

user@server:~$ cd /your/directory

Step 4: Verify that it’s there

user@server:~/your/directory$ ls
latest.tar.gz

Step 5: gunzip it

user@server:~/your/directory$ gunzip latest.tar.gz

Step 6: Unpack the tar ball

user@server:~/your/directory$ tar -xvf latest.tar

*Note: -xvf combines 3 options. -x extracts the file from the archive. -v verbosely lists the files processed. -f uses the archive file.

Step 7: Verify that the wordpress directory is now there…

user@server:~/your/directory$ ls
wordpress

Presto! Now just set up the mysql database, edit wp-config.php, and go to http://yourdomain.com/wordpress/wp-admin/install.php to complete the final steps.

Create a MySQL Database, Username, Password, and Privileges from the command line

Posted by: on Aug 30, 2011 in News, Support | No Comments

Step 1: Login to MySQL ( you will need an account )

user@server:~$ mysql -u mysql_user -p
Enter password:

Step 2: Create the Database

mysql > create database db_name;

Step 3: Verify that it’s there

mysql > show databases;

Step 4: Create the User

mysql > create user db_user;

Step 5: Grant privileges while assigning the password

mysql > grant all on db_name.* to 'db_user'@'localhost' identified by 'db_password';

*Note: The localhost field usually doesn’t have to be edited, but you can set it to the specific address.

The above example grants all privileges, obviously. But you will likely want to limit privileges under many circumstances. These parameters include select, insert, and delete.
Choose all that apply and separate by comma, thusly:

mysql > grant select, insert, delete on db_name.* to 'db_user'@'localhost' identified by 'db_password';

Yahoo! Media Player

Posted by: on Aug 19, 2011 in News, Open Source Media Players, Support | No Comments

This innovative script from Yahoo! has automatically detected the following textual MP3 links and embedded a simple play button next to each of them.

  1. Afterworld
  2. Frame Of Reference
  3. The Heart To Tell
  4. Watch Your Step
  5. Coma Fantasy
  6. Remiss

It also automatically organizes all recognized MP3 links within the page into a playlist, which appears when any play button is clicked. Furthermore, visitors can choose to keep the playlist running in a separate window while they continue to browse your site.
All you need to do is add the normal textual MP3 links you see above as the highlighted song titles, and place the following code somewhere above the first link (place it in the <head> tag to use exclusively throughout the site):

<script type="text/javascript" src="http://mediaplayer.yahoo.com/js"></script>

About: JavaScript-based. Automatically embeds play button next to audio links. Creates playlist out of all audio links on page. Option to open playlist in new tab/window.
Positive: Easiest setup – by Far ! Create an MP3 link, and it’s there! The button design is neutral enough to blend in with any site.
Negative: Buffering could be smoother – I have noticed some clipping on larger files. You are stuck with a “master” playlist – cannot break it up into smaller groups. Also stuck with the built-in player design, including the floating button seen in the bottom-left of the screen.
Source: Yahoo! Media Player

Google Reader Player

Posted by: on Aug 19, 2011 in News, Open Source Media Players, Support | No Comments

This simple Flash-based code from Google embeds the following player controls.

<embed type="application/x-shockwave-flash" width="400" height="27" src="http://www.google.com/reader/ui/3523697345-audio-player.swf" flashvars="audioUrl=http://yourdomain.com/audio_files/song.mp3" quality="best"></embed>

Features: Flash-based. Plays single track/file.
Positive: Great for the occasional sound clip & large files. Easy to swap in your own MP3 file paths.
Negative: Cannot modify colors/dimensions. Sticks out like a sore thumb.
Source: Google Reader Player

Play Tagger by Delicious

Posted by: on Aug 19, 2011 in News, Open Source Media Players, Support | No Comments

Not shown. As easy to setup as Yahoo! Media Player…

<script src="http://static.delicious.com/js/playtagger.js" type="text/javascript"></script>

… but doesn’t readily display as expected. Also, hitting play bumps the corresponding text to the right for no apparent reason.
Positive: Easy implementation.
Negative: Button doesn’t automatically align to text. Can’t change color.
Source: Play Tagger by Delicious

Audio Player (WordPress Plugin)

Posted by: on Aug 19, 2011 in News, Open Source Media Players, Support | No Comments

A WordPress Plugin that adds this sleek Flash controller to the MP3 files of your choice. Also available as a stand-alone

Audio clip: Adobe Flash Player (version 9 or above) is required to play this audio clip. Download the latest version here. You also need to have JavaScript enabled in your browser.

Positive: Stylish. Can match your theme’s color scheme.
Negative: Requires additional CSS/HTML coding to control positioning on the page. Not easily managed by non-developers.
Source: WPAudioPlayer.com