Tampilkan postingan dengan label linux. Tampilkan semua postingan
Tampilkan postingan dengan label linux. Tampilkan semua postingan

Kamis, November 17, 2011

Bash : Auto Delete Old Backup Files

Based on my experience on maintenance project.
It's about to create auto delete old backup files on Mandriva 2005 (Linux) server.

This article is related with this article

After create backup file there will be alot of files created in our backup folder.
So we need an auto delete old backup files.

1. Create recycle.sh
$ mcedit /recycle.sh

File content :

#! /bin/sh
find /backup | grep `date -d '1 week ago' +%Y-%m-%d` | xargs --no-run-if-empty rm

2. Edit crontab

$ mcedit /etc/crontab

File Content :

SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
HOME=/

# run-parts
00 15 * * 1-6 root /bin/sh /recycle.sh

3. Reconfigure your crontab

$ crontab -u[username] /etc/crontab
$ crontab -l

Auto delete scheduled every Monday through Friday 2 pm :)

Modified from : http://unix.stackexchange.com

Bash : Auto Backup Mysql on Mandriva 2005

Based on my experience on maintenance project.
It's about to create auto backup mysql on Mandriva 2005 (Linux) server.

1. Create file backup.sh, you may using mc or pico

$ mcedit /backup.sh

File content :

#! /bin/sh
/usr/bin/mysqldump -u[username] -p[password] [database_name] > /[your_backup_directory]/[filename].sql
cd /backup
tar --remove-files -czf backup-`date '+%Y-%m-%d' `.tar.gz -R *.sql
sudo cp -f *.tar.gz /[another_backup_directory]

2. Edit your cron list

$ mcedit /etc/crontab

File content :

SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
HOME=/

# run-parts
00 7-14 * * 1-6 root /bin/sh /backup.sh

3. Reconfigure your crontab

$ crontab -u[username] /etc/crontab
$ crontab -l

MySQL auto backup scheduled every Monday through Friday beginning at 7 am till 2 pm :)

Minggu, Juni 15, 2008

Tutorial Auto Backup Database on Linux Server

Yesterday I and my wife went to RSUD Karanganyar to install and create auto backup database on Linux server.
I use Mandriva 2008 as an OS because it's easy to install.

After success installation, I created script to crontab every hour.
Here is my script, of course it's not my own script.

Ok, coffee and smoking mode on


Once again, this is not my own script, I modified from here.


1. Type this command in shell :


bash$ echo your_host:5432:your_user:your_db:your_pass > ~/.pgpass
bash$ chmod 600 ~/.pgpass


2. Create backup.sh in directory /backup and name it as backup.sh
:

#!/bin/sh
/usr/bin/pg_dump -D -U qwe simrs --no-owner > /backup/simrs.sql
cd /
cd /backup
tar --overwrite --remove-files -czf /backup/simrs-`date '+%Y-%m-%d'`.tar.gz -R *.sql
chmod ugo+r -R *
cp -f *.* /var/www/html/backup
cp -f *.* /mnt/win_d/backup


3. Edit /etc/crontab and add bold line in crontab file :


SHELL=/bin/bash

PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
HOME=/
# run-parts
01 * * * * root nice -n 19 run-parts --report /etc/cron.hourly
01 * * * * root /backup/backup.sh #<-- add this line
02 4 * * * root nice -n 19 run-parts --report /etc/cron.daily
22 4 * * 0 root nice -n 19 run-parts --report /etc/cron.weekly
42 4 1 * * root nice -n 19 run-parts --report /etc/cron.monthly


4. run crontab as root

root@server:~# crontab -u root /etc/crontab


5. check one hour later, or just type :

root@server:~# crontab


After I check /backup directory there is new file simrs-data.tar.gz
I check again at /var/www/html/backup directory, there is also new file simrs-date.tar.gz
I double check again at /mnt/win_d/backup directory, well... it's succeeded

Thanks to open source community :)

Minggu, Juni 01, 2008

Tutorial Howto Install Squid on Windows

- Kangkam -

Squid is opensource software that use by many server for :
1. control an internet access
2. share bandwidth
3. faster loading process for a website that have open before
4. etc... :D

You can download a squid for windows version here or here

Now this is the step by step configuration :

download squid-2.6.STABLE18-bin-DELAYP.zip

extract to C:

enter C:\squid\etc folder

open squid.conf.default and save as to squid.conf

open mime.conf.default and save as to mime.conf

open cachemgr.conf.default and save as to chachemgr.conf

open squid.conf with notepad or wordpad

press ctrl + F buttons (to search a word)

find our_networks word
#acl our_networks src 192.168.1.0/24 192.168.2.0/24
#http_access allow our_networks
delete # / uncomment them, so it will be like this :
acl our_networks src 192.168.1.0/24 192.168.2.0/24
http_access allow our_networks
press ctrl + F button again

find visible_hostname word
# TAG: visible_hostname
# If you want to present a special hostname in error messages, etc,
# define this. Otherwise, the return value of gethostname()
# will be used. If you have multiple caches in a cluster and
# get errors about IP-forwarding you must set them to have individual
# names with this setting.
#
#Default:
# none <-- change="change" font="font" style="font-style: italic; font-weight: bold;">#none
with ... i.e. localhost
# TAG: visible_hostname
# If you want to present a special hostname in error messages, etc,
# define this. Otherwise, the return value of gethostname()
# will be used. If you have multiple caches in a cluster and
# get errors about IP-forwarding you must set them to have individual
# names with this setting.
#
#Default:
visible_hostname localhost
press ctrl + F button again

find dns_nameservers word
# TAG: dns_nameservers
# Use this if you want to specify a list of DNS name servers
# (IP addresses) to use instead of those given in your
# /etc/resolv.conf file.
# On Windows platforms, if no value is specified here or in
# the /etc/resolv.conf file, the list of DNS name servers are
# taken from the Windows registry, both static and dynamic DHCP
# configurations are supported.
#
# Example: dns_nameservers 10.0.0.1 192.172.0.4
#
#Default:
# none
change #none with your dns server (i.e. : 202.134.0.155 or 202.134.2.5 or 208.67.222)
# TAG: dns_nameservers
# Use this if you want to specify a list of DNS name servers
# (IP addresses) to use instead of those given in your
# /etc/resolv.conf file.
# On Windows platforms, if no value is specified here or in
# the /etc/resolv.conf file, the list of DNS name servers are
# taken from the Windows registry, both static and dynamic DHCP
# configurations are supported.
#
# Example: dns_nameservers 10.0.0.1 192.172.0.4
#
#Default:
dns_nameserver 208.67.222.222
save and close squid.conf document



enter c:\squid\sbin directory
type C:\squid>sbin\squid.exe –i

then type C:\squid>sbin\squid.exe –z

open start menu - setting - control panel - administrative tools - services

find service squid

click start



open browser (i.e. mozilla)

choose from menu bar : tools - option - network - setting

choose manual proxy and enter your computer ipaddress with default squid port (3128)
press ok and ... browsing :)

have it try ...

- Kangkam -

Jumat, Mei 30, 2008

Cloning Hardisk On Linux

- Kangkam -

I have found this article long ago, i never have a chance to try it, but this article still valuable to documented.

=================================================

Cloning Hardisk (On Linux)

Written by Aris Wendy Sunyoto [aris_wendy at yahoo dot com]
Tuesday, 22 February 2005

Beberap hari lalu Om dadan (genk-ijo) cerita kalo habis cloning hardisk customernya dengan OS linux. Yang bikin lucu dan geli how to nya kok sesimple gitu ya.....Apa nggak ada securitynya atau yang bisa blocking cara seperti itu ?Hanya dengan memasang HD kosong kemudian dengan cara :

1. cat /dev/sda > /dev/sdc &

sudah tercopy semua isinya beserta database yang ada didalamnya... :)) . Hmm jadi penasaran dibuatnya penulis mencoba dengan command lain yaitu :

2. dd if=/dev/sda of=/dev/sdc &

http://natnit.net/warnet/okenet/51/

- Kangkam -