Bash script to Backup Android SD Card

I just created simple bash script to backup my android sd card phone, you can freely used it with the adjustment according to your phone setting and files you want backup.

#!/bin/bash
# author : rachmat.febrianto@gmail.com
# script to backup content : images and e-book of sdcard 
# for android mobile phone

prog=phone_backup.sh
bkp_source1=DCIM
bkp_source2=e-book
bkp_target=/home/rachmat/backup/`date +%y-%m-%d`
sdcard_dir=/mnt/sdcard
sdcard_dev=/dev/sdd1

function check_dir_dev(){
	echo "Checking existance of $sdcard_dir directory ..."
	if [ -d $sdcard_dir ]; then
		echo "The $sdcard_dir directory exist"
		echo ""
	else
		echo "The $sdcard_dir directory doesn't exist"
		echo "Creating $sdcard_dir directory ..."
		echo ""
		mkdir $sdcard_dir
	fi

	echo "Checking existance of $sdcard_dev block special device ..."
	if [ -e $sdcard ]; then
 		echo "the $sdcard_dev block special device exist"
		echo ""
		mounting
		backup
	else
		echo "the $sdcard_dev block special device doesn't exist"
		echo "please consult to your administrator."	
		echo ""
	exit 1;
	fi
}

function mounting(){
	mount $sdcard_dev $sdcard_dir
	if [ $? == 0 ]; then
		echo "$sdcard_dev mounted on $sdcard_dir"
	else
		echo "Error with error code $?"
	fi
}

function backup(){
	echo "Backup start, please wait for a while ..."
	mkdir $bkp_target
	cp -r $sdcard_dir/$bkp_source1 $bkp_target
	cp -r $sdcard_dir/$bkp_source2 $bkp_target
	chown -R rachmat:rachmat $bkp_target
	umount $sdcard_dir
	echo "Backup finish, please check $bkp_target directory"
}

case "$1" in 
	backup)
		check_dir_dev;;
	*)	echo "usage: $prog {backup}"
esac

Installing Cacti On Oracle Linux

cacti

Just test and installing Cacti on Oracle Linux 6.4
Before you go ahead installing cacti on your linux distrubition, there are some requirement to fullfill.

Cacti required :
1. AMP : Apache, Mysql, PHP
2. Some packages : RRDTool, net-snmp

Assumming your AMP is running, and we can go ahead to next steps.

1. Downloding latest cacti

http://www.cacti.net/download_cacti.php

2. Extract it into your http web folder, in linux tipically : /var/www/html

3. prepare database to be used by cacti:
– login mysql and create database and cacti user and grant it with following sql command:

CREATE USER 'cacti'@'localhost' IDENTIFIED BY '***';GRANT USAGE ON *.* TO 'cacti'@'localhost' IDENTIFIED BY '***' WITH MAX_QUERIES_PER_HOUR 0 MAX_CONNECTIONS_PER_HOUR 0 MAX_UPDATES_PER_HOUR 0 MAX_USER_CONNECTIONS 0;CREATE DATABASE IF NOT EXISTS `cacti`;

 

GRANT ALL PRIVILEGES ON `cacti`.* TO 'cacti'@'localhost';

4. Import default cacti database with cacti.sql
you can get file “cacti.sql” inside your cacti folder that you just extracted.

[root@localhost cacti]# pwd
/var/www/html/cacti
[root@localhost cacti]# ls -l cacti.sql
-rw-r--r-- 1 1000 users 178349 Aug  7 09:31 cacti.sql
[root@localhost cacti]#
[root@localhost cacti]# mysql -u root -p cacti < cacti.sql

5. Open your browser to install cacti. http://localhost/cacti
and follow the instruction.

Screenshot

viola.. installation is done. now you can login with default usernam and password :
username : admin
password : admin

Enable anonymous ftp on Solaris 10

astrounaut_cat

Here the simple step to enable anonymous ftp on Solaris 10:

# ftpconfig -d /export/home/ftp_anonymous
Creating directory /export/home/ftp_anonymous
Updating directory /export/home/ftp_anonymous

# ls /export/home/ftp_anonymous
bin  dev  etc  lib  pub  usr

# ftpconfig /export/home/ftp_anonymous
Creating user ftp
Updating directory /export/home/ftp_anonymous

# svcadm enable svc:/network/ftp:default

# svcs -a | grep ftp
online         18:30:19 svc:/network/ftp:default

Testing from client side:

$ ftp 192.168.56.10
Connected to 192.168.56.10 (192.168.56.10).
220 solaris FTP server ready.
Name (192.168.56.10:rachmat): anonymous
331 Guest login ok, send your complete e-mail address as password.
Password:
230 Guest login ok, access restrictions apply.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> dir
227 Entering Passive Mode (192,168,56,10,251,189)
150 Opening ASCII mode data connection for /bin/ls.
total 16
lrwxrwxrwx   1 root     bin            9 Oct 19 18:29 bin -> ./usr/bin
d--x--x--x   2 root     sys            7 Oct 19 18:29 dev
d--x--x--x   5 root     sys            8 Oct 19 18:29 etc
d--x--x--x   2 root     bin           23 Oct 19 18:29 lib
drwxr-xr-x   2 root     sys            2 Oct 19 18:24 pub
d--x--x--x   6 root     sys            6 Oct 19 18:24 usr
226 Transfer complete.
ftp> bye
221-You have transferred 0 bytes in 0 files.
221-Total traffic for this session was 780 bytes in 1 transfers.
221-Thank you for using the FTP service on solaris.
221 Goodbye.

Extend root filesystems on Oracle Linux

Before you begin :
1. Verify your new disk is detect on the systems
in this case, I’m using /dev/sdb
2. Identify your volgroup
in this case, my my root vg is vg_allen.

Here we go :

[root@allen ~]# fdisk /dev/sdb 
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0x079df05d.
Changes will remain in memory only, until you decide to write them.
After that, of course, the previous content won't be recoverable.

Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
         switch off the mode (command 'c') and change display units to
         sectors (command 'u').

Command (m for help): 
Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-1566, default 1): 
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-1566, default 1566): 
Using default value 1566

Command (m for help): t
Selected partition 1
Hex code (type L to list codes): 8e
Changed system type of partition 1 to 8e (Linux LVM)

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.
[root@allen ~]# fdisk -l

Disk /dev/sda: 12.9 GB, 12884901888 bytes
255 heads, 63 sectors/track, 1566 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0009af64

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          64      512000   83  Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2              64        1567    12069888   8e  Linux LVM

Disk /dev/sdb: 12.9 GB, 12884901888 bytes
255 heads, 63 sectors/track, 1566 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x079df05d

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1        1566    12578863+  8e  Linux LVM

Disk /dev/mapper/vg_allen-lv_root: 10.2 GB, 10242490368 bytes
255 heads, 63 sectors/track, 1245 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000


Disk /dev/mapper/vg_allen-lv_swap: 2113 MB, 2113929216 bytes
255 heads, 63 sectors/track, 257 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

[root@allen ~]# partprobe 
Warning: WARNING: the kernel failed to re-read the partition table on /dev/sda (Device or resource busy).  As a result, it may not reflect all of your changes until after reboot.
[root@allen ~]# pvcreate /dev/sdb
sdb   sdb1  
[root@allen ~]# pvcreate /dev/sdb1 
  Writing physical volume data to disk "/dev/sdb1"
  Physical volume "/dev/sdb1" successfully created
[root@allen ~]# vgextend vg_allen /dev/sdb1 
  Volume group "vg_allen" successfully extended
[root@allen ~]# lvextend /dev/vg_allen/lv_
lv_root  lv_swap  
[root@allen ~]# lvextend /dev/vg_allen/lv_root /dev/sdb1 
  Extending logical volume lv_root to 21.53 GiB
  Logical volume lv_root successfully resized
[root@allen ~]# df -h /
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/vg_allen-lv_root
                      9.4G  8.5G  504M  95% /
[root@allen ~]# resize2fs /dev/vg_allen/lv_root 
resize2fs 1.41.12 (17-May-2010)
Filesystem at /dev/vg_allen/lv_root is mounted on /; on-line resizing required
old desc_blocks = 1, new_desc_blocks = 2
Performing an on-line resize of /dev/vg_allen/lv_root to 5644288 (4k) blocks.
The filesystem on /dev/vg_allen/lv_root is now 5644288 blocks long.

[root@allen ~]# df -h /
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/vg_allen-lv_root
                       22G  8.5G   12G  42% /