unix 웹 백업 (쉘 스크립트)
2018.10.14 13:05
#!/bin/bash ### 변수 설정 ### home=/var/www/ # 홈 경로 backup_path=/root/backup/ # 저장할 경로 delete_date="+6" # 6일이 지난 백업본 삭제 www=public_html # 웹 디렉토리 이름 vm_shared=/mnt/backup/ # VMware 공유폴더 ### 예전 자료 삭제 ### find $backup_path*.tar.gz -mtime $delete_date -print -exec rm -rf {} \; ### 서비스 종료 ### wall "Web Backup Start" ### 압축 ### mkdir $backup_path # 혹시 backup 폴더 삭제한 경우;; for folder in $home*/$www do filename=`date +%Y%m%d-%H%M`_${folder#$home} # 20120325_elkha/public_html tar cvfz $backup_path${filename%/$www}.tar.gz $folder # tar cvfz /manage/backup/20120325_elkha.tar.gz /home/elkha/public_html done wall "Web Backup End" ### 백업 파일 이동 ### if [ -d $vm_shared ];then # 오늘 날짜의 파일들을 모두 이동 mv $backup_path`date +%Y%m%d`* $vm_shared # db파일은 용량이 작으니 웹 파일만 삭제한다. find $vm_shared*.tar.gz -mtime $delete_date -print -exec rm -rf {} \; fi
댓글 0
번호 | 제목 | 날짜 | 조회 수 |
---|---|---|---|
21 | 간단하고 강력한 xe 보안 향상 | 2014.11.08 | 1875 |
20 | yum install latest redis | 2019.03.27 | 1682 |
19 | yum install php-apcu | 2019.03.12 | 1544 |
18 | certbot apache multiple domain | 2019.04.10 | 1416 |
» | 웹 백업 (쉘 스크립트) | 2018.10.14 | 1195 |
16 | yum install mariadb [2] | 2018.10.10 | 1145 |
15 | munin 설치 | 2018.10.13 | 787 |
14 | mysql 백업 (shell script) | 2018.10.14 | 697 |
13 | yum install php 7.1 [6] | 2018.10.10 | 689 |
12 | php 에서 비동기 처리하는 방법 | 2023.06.22 | 446 |
11 | apache2 AllowOverride config | 2023.05.23 | 434 |
10 | mysqldump from remote db to my local server. | 2023.05.04 | 421 |
9 | gearman 은 무엇인가? | 2023.06.21 | 383 |
8 | windows hardware encrypt ssd | 2024.01.23 | 310 |
7 | The best configuration of php7.4-fpm / 1.5GB | 2023.05.04 | 29 |
6 | The best configuration of php7.4-fpm / 8GB | 2023.05.04 | 26 |
5 | To download large files with rsync command. | 2023.05.04 | 21 |
4 | my.cnf | 2019.04.11 | 1 |
3 | net::ERR_CONNECTION_REFUSED | 2021.10.11 | 0 |
2 | php-fpm tcp to socket | 2020.01.25 | 0 |