一聚教程网:一个值得你收藏的教程网站

热门教程

CentOS 6.5 64位系统使用百度云免费备份文件

时间:2022-06-30 21:14:52 编辑:袖梨 来源:一聚教程网


环境:
系统版本:CentOS 6.5 x86_64
PHP版本:php 5.3.3

一、介绍

因为自己的vps的空间很小,考虑到我自己的百度云盘有几十T,不使用怪可惜的,但是百度云盘没有Linux版本的,所以有位大神写了一个百度pcs上传脚本,现在需要通过这个脚本来把连接百度云,并且把文件上传到百度云。百度pcs上传脚本官网:http://oott123.github.io/bpcs_uploader/

二、安装配置

1.系统要求

Linux并且需要安装php及curl,php和curl安装不说了

2.安装配置

[root@web_us ~]# wget https://github.com/oott123/bpcs_uploader/tarball/master #下载文件
[root@web_us ~]# tar -zxvf master #解压
[root@web_us ~]# mv oott123-bpcs_uploader-3a75324/ bdy #修改名字为bdy
[root@web_us ~]# cd bdy/
[root@web_us bdy]# chmod a+x bpcs_uploader.php
[root@web_us bdy]# which php
编辑bpcs_uploader.php文件,将第一行的/usr/bin/php修改为查询到的php路径
[root@web_us bdy]# ./bpcs_uploader.php quickinit
出现是否继续的提示 输入y
然后会出现“Input g73gjbbp as the user code if asked.”的提示
然后打开http://openapi.baidu.com/device,然后再g73jbbp,每个人的授权码不一样。
输入完后,完成,等出现“您已成功为bpcs_uploader授权!”回到配置界面,按回车键继续
会出现“Access Granted. Your Storage Status: 0.00G/5.00G (0.00%)” ,连接云盘成功,这个是返回显示云盘空间大小,

bpcs上传脚本就算安装好了

[root@web_us ~]# mv bdy/ /usr/local/

3.操作使用

#上传文件
[root@web_us ~]# /usr/local/bdy//bpcs_uploader.php upload [path_local] [path_remote]
e.g. /usr/local/bdy/bpcs_uploader.php upload /Web/BAK/looking_s_20140914.tar.gz /web/looking_s_20140914.tar.gz
#下载文件
/usr/local/bdy/bpcs_uploader.php download [path_local] [path_remote]
#删除文件
./bpcs_uploader.php delete [path_remote]
e.g. /usr/local/bdy/bpcs_uploader.php delete /web/looking_s_20140914.tar.gz
#离线下载
./bpcs_uploader.php fetch [path_remote] [path_to_fetch]
e.g. /usr/local/bdy/bpcs_uploader.php fetch /web/forai_20140914.tar.gz /tmp/forai_20140914.tar.gz
#查询容量
./bpcs_uploader.php quota
e.g. /usr/local/bdy/bpcs_uploader.php quota

三、使用百度云自动备份脚本分享

#!/bin/bash
webpath=/Web/
mysql_u=root
mysql_p=123456
bakcup_dir=/Web/BAK
log_date=`date +%F`
date_1=`date +%Y%m%d`
file_conf=/tmp/conf_${date_1}
date_2=1
bdy_dir=/usr/local/bdy
logs_dir=/logs
 
if [ ! -d $logs_dir ]
then
 mkdir -p $logs_dir
fi
cd $webpath
echo "Log date: $log_date" >> $logs_dir/backup.log
ls -l | grep "^d" | grep -v "default|dl|Bakcup|BAK" | awk '{print $9}' > site.list
for line in $(cat site.list);
do
 tar -czvf $bakcup_dir/${line}_${date_1}.tar.gz $webpath/$line/public_html/
 $bdy_dir/bpcs_uploader.php upload ${bakcup_dir}/${line}_${date_1}.tar.gz /web/${line}_${date_1}.tar.gz
 if [ `echo $?` -eq "0" ];then
 echo "$line Web file backup succesed! " >> $logs_dir/backup.log
 else
 echo "$line Web file backup failed! " >> $logs_dir/backup.log
 fi
 /usr/local/mysql/bin/mysqldump -u$mysql_u -p$mysql_p $line > $bakcup_dir/${line}_${date_1}.sql
 $bdy_dir/bpcs_uploader.php upload ${bakcup_dir}/${line}_${date_1}.sql /sql/${line}_${date_1}.sql
 if [ `echo $?` -eq "0" ];then
 echo "$line Web file backup succesed! " >> $logs_dir/backup.log
 else
 echo "$line Web file backup failed! " >> $logs_dir/backup.log
 fi
done
rm -rf site.list
find $bakcup_dir -name "*.*" -type f -mtime +${date_2} -exec rm {} ;
mkdir -p $file_conf
cp /etc/my.cnf $file_conf/
cp /usr/local/php/etc/php.ini $file_conf/
cp /usr/local/php/etc/php-fpm.conf $file_conf/
cp -R /usr/local/senginx/conf $file_conf/nginx_conf
cp -R /usr/local/pureftpd/etc $file_conf/ftp_conf
tar -czvf $bakcup_dir/conf_${date_1}.tar.gz $file_conf/
$bdy_dir/bpcs_uploader.php upload ${bakcup_dir}/conf_${date_1}.tar.gz /conf/conf_${date_1}.tar.gz
if [ `echo $?` -eq "0" ];then
 echo "$line Web file backup succesed! " >> $logs_dir/backup.log
else
 echo "$line Web file backup failed! " >> $logs_dir/backup.log
fi
rm -rf $file_conf
#Upload web_file

四、常见问题

问题1:

xxx() has been disabled for security reasons
解决方法:
修改php.ini  把禁用的函数取消

热门栏目