美文网首页
windows和 linux共享 NFS

windows和 linux共享 NFS

作者: liurongming | 来源:发表于2021-12-20 18:21 被阅读0次
需求:需要备份windows下jira服务器附件文件和export目录下数据库文件到linux服务器,避免JIRA服务器故障。
服务器信息如下:
windows共享服务器ip:172.18.5.207   密码:**********
                  共享附件文件夹 D:\Atlassian\Application Data\JIRA\data\attachments
                  共享数据库文件夹 D:\Atlassian\Application Data\JIRA\export
linux客户机IP地址:172.18.7.152
                  共享附件文件夹:/attachments-share
                  共享数据库文件夹:/db-share
                  备份文件夹:/jirabak
                  安装软件:yum install cifs-utils
1、设置windows共享文件夹:
windows映射网络驱动器:
附件文件夹输入:   \\172.18.5.207\attachments
数据库文件夹输入:   \\172.18.5.207\export
输入用户名、密码
2、linux共享文件挂载到windows服务器
mount -t cifs -o username=administrator,password="passwd&2018",uid=500,gid=500 //172.18.5.207/export /db-share/
附件挂载:
mount -t cifs -o username=administrator,password="passwd&2018" //172.18.5.207/attachments  /attachments-share/
数据库挂载:
mount -t cifs -o username=administrator,password="passwd&2018" //172.18.5.207/export /db-share/
开机自动挂载
[root@oracle-test:/jirabak]# cat /etc/rc.local 
#!/bin/sh
mount -t cifs -o username=administrator,password="passwd&2015" //172.18.5.207/export /db-share/
mount -t cifs -o username=administrator,password="passwd&2015" //172.18.5.207/attachments  /attachments-share/
3-1、编写同步附件文件脚本:/jirabak/sync-file.sh 
#!/bin/bash
runtime=`date +'%Y-%m-%d %H:%M:%S'`
echo $runtime' start sync file ---------------' >> /jirabak/sync-file.log
echo 'cp -upnrv /attachments-share/* /jirabak/file-bak/ >> /jirabak/sync-file.log' >> /jirabak/stync-file.log
cp -upnrv /attachments-share/* /jirabak/ >> /jirabak/file-bak/sync-file.log
runtime=`date +'%Y-%m-%d %H:%M:%S'`
echo $runtime' stop sync file ---------------' >> /jirabak/sync-file.log

脚本优化
#!/bin/bash
runtime=`date +'%Y-%m-%d %H:%M:%S'`
src_dir=/home/eipservice/test/2017
dest_dir=/opt/upload/2017
log_file=/home/eipservice/sync-file.log
echo $runtime' start sync file ---------------' >> $log_file
echo "cp -upnrv $src_dir/* $dest_dir/ >> $log_file" >> $log_file
cp -upnrv $src_dir/* $dest_dir/ >> $log_file
runtime=`date +'%Y-%m-%d %H:%M:%S'`
echo $runtime' stop sync file ---------------' >> $log_file

3-2、编写同步数据库文件脚本:/jirabak/sync-db.sh 
#!/bin/bash
runtime=`date +'%Y-%m-%d %H:%M:%S'`
echo $runtime' start sync db-file ---------------' >> /jirabak/sync-db.log
bakfile=`find /db-share/ -mtime -0.5 -name '*.zip'`
echo 'cp -upnrv '$bakfile' /jirabak/database/ >> /jirabak/sync-db.log' >> /jirabak/sync-db.log
cp -upnrv $bakfile /jirabak/database/ >> /jirabak/sync-db.log
runtime=`date +'%Y-%m-%d %H:%M:%S'`
echo $runtime' stop sync db-file ---------------' >> /jirabak/sync-db.log
4、设置定时任务cron
0 1 * * * /jirabak/sync-file.sh
30 1 * * * /jirabak/sync-db.sh
5、重启或者加载crond任务
service ntpd restart

相关文章

网友评论

      本文标题:windows和 linux共享 NFS

      本文链接:https://www.haomeiwen.com/subject/hpmzfrtx.html