2012年8月13日

ntpdate網路校時

安裝
apt-get install ntpdate

執行校時

ntpdate ntp.ntu.edu.tw
ntpdate ntp.ntu.edu.tw

13 Aug 06:48:22 ntpdate[12849]: adjust time server 140.112.2.189 offset -0.141835 sec

FTP上傳備份資料Script


將備份檔案以7zip壓縮並上傳FTP的Script,記綠一下。

backup.sh

#!/bin/bash
bd=$(date +%Y%m%d)
cd /where you want to backup/

tar pcvf - directoryname|7za a -si /bak/directoryname.${bd}.tar.7z

mysqldump -uusername -ppassword dbname > /bak/dbname.${bd}.sql
svnadmin dump /home/svn/repository/project > /bak/project.dump

cd /bak/

HOST='IP'
USER='username'
PASS='password'
ftp -ivn $HOST << EOF
user $USER $PASS
bin
put backupfilename
quit
EOF


Note:FTP常用指令
ls     查看 Server 端的目錄或檔案
pwd    查看 Server 端目前所在的目錄
cd     變更 Server 端目前的目錄
cdup   變更 Server 端目前的目錄到上一目錄
lls    查看 Local 端的目錄或檔案
lcd    變更 Local 端目前的目錄
asc    設定傳輸模式為文字檔方式
bin    設定傳輸模式為二進位檔方式
get    將 Server 端的檔案拷貝至 Local 端現在目錄下
mget   拷貝多個 Server 端的檔案至 Local 端現在目錄下
put    將 Local 端的檔案拷貝至 Server 端現在目錄下
mput   拷貝多個 Local 端的檔案至 Server 端現在目錄下
delete 刪除 Server 端的檔案
mkdir  在 Server 端建立目錄
rmdir  刪除 Server 端的目錄
!      shell 指令
!ls    查看 Local 端的目錄或檔案
prompt 變換交談模式 (on/off),
?,help 指令使用說明
bye    結束 FTP

2012年8月1日

Samba安裝筆記

apt-get install samba

編輯/etc/samba/smb.conf
[global]
   workgroup = WORKGROUP
   display charset = UTF8
   dos charset= cp950
   unix charset= UTF8
   server string = server description
   dns proxy = no
;   name resolve order = lmhosts host wins bcast
;   interfaces = 127.0.0.0/8 eth0
;   bind interfaces only = yes
#### Debugging/Accounting ####
   log file = /var/log/samba/log.%m
   max log size = 1000
   syslog = 0
   panic action = /usr/share/samba/panic-action %d
   security = share
   encrypt passwords = true
   passdb backend = tdbsam
   obey pam restrictions = yes
   unix password sync = yes
   passwd program = /usr/bin/passwd %u
   passwd chat = *Enter\snew\s*\spassword:* %n\n *Retype\snew\s*\spassword:* %n\n *password\supdated\ssuccessfully* .
   pam password change = yes
#======================= Share Definitions =======================
   read only = yes
   create mask = 0700
   directory mask = 0700
   vaild users = %s

[250g1]
comment = 250g1
path = /250g1
guest ok = yes
writable = yes
share modes = yes
[250g2]
comment = 250g2
path = /250g2
guest ok = yes
writable = yes
share modes = yes