1. Skip to Menu
  2. Skip to Content
  3. Skip to Footer>
Image 1

WE Solutions / Our services

  • Previous
  • Next
  • Stop
  • Play

SAMBA/LDAP

Thin Client Server

Postfix Mail Server

Postfix Mail Server

HA Clustering


Warning: Parameter 3 to mb_videobot() expected to be a reference, value given in /home/www/virtual/susethailand.com/htdocs/libraries/joomla/event/dispatcher.php on line 136

Tar Backup

PDF Print E-mail

Written by Mr. Sontaya Photibut Saturday, 02 May 2009 19:13

การใช้คำสั่ง Tar ในการ Backup และ Restore (Advance)

ตัวอย่าง เป็นการ backup profile users

Backup /home 

# vi backup-profile.sh

<!#/bin/bash

cd /home

tar -zcvpf /backup/profile.tar.gz --exclude-from=/home/backup/exclude -g /home/backup/snapfile /home

จากนั้นทำการ Save กด :wq!

อธิบาย สักนิดนะ ภาษาบ้านๆ เลย

--exclude-from=/home/backup/exclude คือไม่ backup ข้อมูลที่อยู่ในเงื่อนไงในไฟล์ exclude นี้ เช่นถ้าคุณไม่ต้องการ backup ไฟล์ mp3 คุณก็เขียนเงื่อนไงลงในไฟล์ exclude 

-g คือจะ backup ไฟล์ที่มีการแก้ไขเ่ท่านั้น เราก็จะลงเรื่องการ backup files เก่าๆ ทุกๆ วัน 

การสร้างไฟล์ exclude

# vi /home/backup/exclude

*.mp3

*.

แล้วทำการ Save กด :wq!

Restore /home 

# cd /home 

# tar -zxf /home/backup/profile.tar.gz 

สร้าง crontab

# crontab -e 

10 1 * * * /root/backup-profile.sh 

คือ Script จะทำงานตอนเวลาตี 1 / 10 นาที ของทุกวัน 

 
จบแล้วครับ เป็นไงบ้างครับ เข้าใจง่ายไหม 

 

 

 

 

 


Comments (0)Add Comment

Write comment

security code
Write the displayed characters


busy