freebsd下备份文件至amazon s3

ports安装ruby1.8
cd cd /usr/ports/lang/ruby18/
sudo make install clean
cd /usr/ports/converters/ruby-iconv
sudo make install

fetch http://s3.amazonaws.com/ServEdge_pub/s3sync/s3sync.tar.gz
tar xvzf s3sync.tar.gz
cd s3sync

设置环境变量
export AWS_CALLING_FORMAT=SUBDOMAIN
export AWS_ACCESS_KEY_ID=3Shde^#hf
export AWS_SECRET_ACCESS_KEY=SD42c

ruby s3sync.rb -r /home/hoho bucket:backup/

shell备份按条件
#!/bin/bash
#!/bin/bash
export AWS_CALLING_FORMAT=SUBDOMAIN
export AWS_ACCESS_KEY_ID=××
export AWS_SECRET_ACCESS_KEY=××

cur_dir="/home/xxx/public_html/userdata/store1/"
echo $( date -u +%s)
#du -k ~/|tail -1| cut -d '/' -f 1
for((i=190;i<=190;i++));
  do
   dir="$cur_dir$i"
   if [  -d "$dir" ]; then
   #echo $dir
   ruby s3sync.rb -r $dir  m1.xxx.com:store1/

   fi
  done
echo $( date -u +%s)

你可能感兴趣的:(FreeBSD)