linux和windows跨平台文件系统备份-147

linux系统文件备份到windows系统(windows启用samba服务,Linux通过smb客户端备份到windows)


windows系统配置(server 2008 r2 ,linux (centos 5.5))

1.创建共享备份路径

\\10.0.3.3\adbackup\IBack

2.创建本地用户:lwy pass:lwy123 允许访问IBack的权限


linux客户端配置(linux centos 5.5)

yum install samba-client -y


1)自动备份--现在使用

//挂载到本地

# mount -t smbfs -o username=xxx,password=xxx //hostname/dir /mnt/bk

mount: unknown filesystem type 'smbfs'

centos 5.5没有smbmount了,也没有支持smbfs,而改用了Common Internet File Systemcifs(cifs)取代了原有的smbfs,所以命令就改为:

# mount.cifs //10.0.3.3/adbackup/IBack /mnt/bk -o username=lwy

Password:


备份脚本:

//时间格式$date=`date +%Y-%m-%d" "%H:%M`/date +%Y%m%d%H%M

脚本目录:/home/back/


noon.sh

#!/bin/bash

/usr/local/mysql/bin/mysqldump --opt -uroot -pItec2012 ITI >/mnt/bk/mysql/mysql-`date +%Y%m%d%H%M`.sql

night.sh

#!/bin/bash

/usr/local/mysql/bin/mysqldump --opt -uroot -pItec2012 ITI >/mnt/bk/mysql/mysql-`date +%Y%m%d%H%M`.sql

itI.sh

#!/bin/bash

tar zcvf /mnt/bk/itI/itI-`date +%Y%m%d%H%M`.zip  /usr/local/apache/htdocs/ITI/*


crontab -e

[root@I back]# crontab -e

30 12 * * * /home/back/noon.sh

30 02 * * * /home/back/night.sh

30 02 * * 0 /home/back/itI.sh



2)手动备份

//手动上传到windows

# smbclient //10.0.3.3/backup/ADbackup/IBackup/I -U lwy

Password:

//或者以这个方式登录:smbclient //10.0.3.3/backup/ADbackup/IBackup/I -U lwy%lwy123

smb: \> cd IBackup/I/itI

smb: \IBackup\I\itI\> lcd /home/back/itI/

smb: \IBackup\I\itI\> mput *

smb: \> cd IBackup/I/mysql/

smb: \IBackup\I\mysql\> lcd /home/back/mysql/

smb: \IBackup\I\mysql\> mput *

Put file 201301031230.sql? y

putting file 201301031230.sql as \IBackup

smb: \>q


本文出自 “yanzi” 博客,谢绝转载!

你可能感兴趣的:(备份)