首页 > 系统相关 >Linux 纯shell备份文件

Linux 纯shell备份文件

时间:2022-10-25 11:00:07浏览次数:37  
标签:shell remote Number 备份文件 add Linux backups backup store

  • 克隆项目并进入项目目录:git clone https://github.91chi.fun/https://github.com/Pricetx/backup.git;cd backup

  • 创建所需目录:mkdir -p /root/backups/temp/

  • 添加脚本可执行权限:chmod +x backup.sh

  • 编辑配置文件backup.cfg,注释写的很清楚,要配置的也不多,注意:最好给该配置文件配置权限为044,因为里面存放了加密密码

    ### BACKUP CONFIGURATION ###
    
    # KEEP THE PASSWORD SAFE. It is HIGHLY recommended to chmod 400 this file so 
    # that other users can not read it
    
    # To decrypt backups made by this script, run the following command:
    # openssl enc -aes256 -in [encrypted backup] -out decrypted_backup.tgz -pass pass:[backup password] -d -md sha1
    #解密命令:openssl enc -aes256 -in 加密文件名.tgz.enc -out decrypted_backup.tgz -pass pass:解密密码 -d -md sha1
    
    ## Edit the entries below to match your needs ##
    
    # The password used to encrypt the backup
    # NOTE: MAKE SURE THAT YOU CHMOD THIS FILE TO 400 TO AVOID UNAUTHORISED ACCESS
    BACKUPPASS="mysecurepassword"
    
    # Directory to store backups
    #存放本机本分文件路径
    LOCALDIR="/root/backups/"
    
    # Temporary directory used during backup creation
    TEMPDIR="/root/backups/temp/"
    
    # File to log the outcome of backups
    LOGFILE="/root/backups/backup.log"
    
    # Number of days to store daily local backups
    LOCALAGEDAILIES="7"
    
    # Number of days to store daily remote backups
    REMOTEAGEDAILIES="7"
    
    # Number of days to store weekly local backups
    LOCALAGEWEEKLIES="28"
    
    # Number of days to store weekly remote backups
    REMOTEAGEWEEKLIES="28"
    
    # Number of days to store monthly local backups
    LOCALAGEMONTHLIES="183"
    
    # Number of days to store monthly remote backups
    REMOTEAGEMONTHLIES="183"
    
    # IP / hostname of the server to store remote backups
    #远程主机IP,即你要把备份文件传到哪台服务器上
    REMOTESERVER="REMOTE_SERVER_HERE"
    
    # SSH port of remote server
    REMOTEPORT=22
    
    # User to use with SSH (public key needs to be installed on the remote server)
    #远程主机用户名(该配置文件中没有配置密码,是因为通过公钥连接的,可以使用ssh-copy-id 用户名@主机名,将公钥放在远程主机上)
    REMOTEUSER="REMOTE_USER_HERE"
    
    # Path to store the remote backups
    #远程主机存放备份文件路径,注意要保证路径存在,且权限正确
    REMOTEDIR="/BACKUP/PATH/ON/REMOTE/SYSTEM/"
    
    # Limit bandwidth used by SCP, in Kbit/s. Set to 0 for unlimited.
    SCPLIMIT=0
    
    # OPTIONAL: If you want MySQL to be backed up, enter the root password below
    #如果要备份数据库的话,填写mysql数据库密码
    ROOTMYSQL=""
    
    # Below is a list of files and directories that will be backed up in the tar
    # backup. To add an entry, add a new line with the same format
    #需要备份的文件路径
    BACKUP+=("/root/backup.cfg")
    BACKUP+=("/etc/")
    
    # Files and directories to exclude from tar backups
    # To add an entry, add a new line with the same format
    # NOTE: DO NOT LEAVE A TRAILING SLASH ON LINUX - IT WILL CAUSE IT TO NOT WORK
    #需要排除的文件路径
    EXCLUDE+=("")
    
    # Below is a list of files and directories that will be backed up in the rsync
    # backup. To add an entry, add a new line with the same format
    # NOTE: DO NOT LEAVE A TRAILING SLASH - IT WILL CAUSE IT TO NOT WORK
    RSYNCDIR+=("")
    

标签:shell,remote,Number,备份文件,add,Linux,backups,backup,store
From: https://www.cnblogs.com/steinven/p/16824167.html

相关文章

  • shell中sort的用法
    练习文本catcargo.dbThinkPad:USA:14000:2009:X301ThinkPad:HongKong:10000:2008:T400ThinkPad:USA:8000:2007:X60HP:China:5600:2010:DM3HP:China:12000:2010:NE80......
  • linux 清理java缓存,Linux手动释放缓存的方法
    Linux释放内存的命令:syncecho1>/proc/sys/vm/drop_cachesdrop_caches的值能够是0-3之间的数字,表明不一样的含义:0:不释放(系统默认值)1:释放页缓存2:释放dentries和in......
  • linux如何使用umount命令强制卸载文件系统
    https://www.cnblogs.com/ss-33/p/13884639.htmlumount命令解挂文件系统。umount[-ahnrvV][-t《文件系统类型》][文件系统]umount可卸除目前挂在Linux目录中的文......
  • linux获取tick值
    #include<time.h>//返回自系统开机以来的毫秒数(tick)unsignedlongGetTickCount(){structtimespects;clock_gettime(CLOCK_MONOTONIC,&ts);re......
  • 【linux】两台服务器免密传输
    两台服务器免密传输参考:两台服务器免密传输A,B两台机子想免密传输如果没有做免密传输,每次都需要输入密码,就非常麻烦个人只做了A向B传输文件的操作,操作步骤如下:1、在A......
  • Linux下Mysql数据库名及表名区分大小写设置
    微信公众号:IT邦德在MySQL中,一个数据库会对应一个文件夹,数据库里的表会则以文件的方式存放在文件夹内,所以,操作系统对大小写的敏感性决定了数据库和表的大小写敏感。Linux......
  • Linux 中如何开启端口?
    Linux端口的开启Linux端口的开启一、firewall方式(centOS7.*)二、修改iptables方式(centOS6.*)一、firewall方式(​​centOS7.*​​)查看防火墙状态firewall-cmd-......
  • linux 关机方法
    虚拟机是虚拟技术的一种,很多用户会在虚拟机上边使用命令来进行自定义操作关机,这样方便快捷,能够有更多的时间处理别的事情,那么还有没有其他更容易操作的poweroff关机命令呢?......
  • Linux系统配置cron定时任务
    创建用户:groupadd-g567testuseradd-u567-gtest-d/home/v-mvchowntest:test/home/v       ......
  • linux添加硬盘进行扩容
    一、登陆系统查看。​发现有两个目录需扩容,其中一个确实已经100%了,如下图所示:​​​​首先考虑通过vg剩余的空间来扩容,我们来查看vg02组的大小,这里有两个vg组,需要注意的是,我......