Linux Ask!

Linux Ask! is a Q & A web site specific for Linux related questions. Questions are collected, answered and audited by experienced Linux users.

Linux Ask!

Jun 072011
 

Perform XtraBackup and zip to a file

Answer:

In the previous article, we have discussed how to perform a hot backup on InnoDB with XtraBackup , but is it possible to zip the result directly to a file?

Sure, you can use the wrapper script came with the XtraBackup - innobackupex

For example, to backup and zip the result files to zipped files, you can use:

# innobackupex --stream=tar ./ | gzip - > backup.tar.gz

Jun 052011
 

Create a swap partition using LVM

Answer:

To create a swap partition using LVM, you just need a few commands!

1. Create a 1G swap partition

# lvcreate -L 1G -n /dev/vg0/swap0

2. Set up a Linux swap partition

# mkswap /dev/vg0/swap0

3. Enable it

# swapon -s /dev/vg0/swap0

You might also want to put the settings in the /etc/fstab, so it will be mounted automatically when your system boot next time.

# sudo vi /etc/fstab

/dev/vg0/swap0       none            swap     sw              0       0

Save and restart your system to test if it is working when system reboot.

Jun 032011
 

How to echo string to standard error (stderr)?

Answer:

To echo string to the standard error (stderr), rather than the standard output (stdout), you can define the following function in your shell (put in your ~/.bashrc file)

# function echo2() { echo "$@" 1>&2; }

Then you can execute the command like:

# echo2 test

Jun 012011
 

Simple for loop in Bash shell

Answer:

A simple for loop in Bash shell would like the following. You can use it wisely to skip a lot of repetitive tasks.

#!/bin/bash

for i in {1..10}
do
   echo "I am command No. $i"
done