본문 바로가기
IT

서버 백업 용량

by Oh.mogilalia 2024. 4. 15.

서버 / 용량

root@Gugeosigan:/# df -h
Filesystem      Size  Used Avail Use% Mounted on
udev            926M     0  926M   0% /dev
tmpfs           200M  4.5M  195M   3% /run
/dev/sda1       447G   38G  387G   9% /
tmpfs           996M     0  996M   0% /dev/shm
tmpfs           5.0M     0  5.0M   0% /run/lock
tmpfs           996M     0  996M   0% /sys/fs/cgroup
/dev/mmcblk1p1  128M   18M  110M  14% /media/boot
/dev/sda2       100G   63G   38G  63% /media/hdd2
/dev/sda3       1.3T  739G  571G  57% /media/hdd3
tmpfs           200M     0  200M   0% /run/user/0

root@Gugeosigan:/# du -hs /bin
7.3M    /bin
root@Gugeosigan:/# du -hs /boot
112M    /boot
root@Gugeosigan:/# du -hs /etc
7.2M    /etc
root@Gugeosigan:/# du -hs /home
30G     /home
root@Gugeosigan:/# du -hs /lib
785M    /lib
root@Gugeosigan:/# du -hs /opt
4.0K    /opt
root@Gugeosigan:/# du -hs /root
112K    /root
root@Gugeosigan:/# du -hs /sbin
6.8M    /sbin
root@Gugeosigan:/# du -hs /srv
4.0K    /srv
root@Gugeosigan:/# du -hs /sys
0       /sys
root@Gugeosigan:/# du -hs /usr
1.3G    /usr
root@Gugeosigan:/# du -hs /var
1.5G    /var
root@Gugeosigan:/# du -hs /bckup
2.9G    /bckup
root@Gugeosigan:/# du -hs /dev
0       /dev
root@Gugeosigan:/# du -hs /mnt
1.1G    /mnt
root@Gugeosigan:/# du -hs /run
4.5M    /run
root@Gugeosigan:/# du -hs /media
801G    /media
root@Gugeosigan:/media# ls
boot  hdd  hdd2  hdd3  usb
root@Gugeosigan:/media# du -hs boot/
18M     boot/
root@Gugeosigan:/media# du -hs hdd/
4.0K    hdd/
root@Gugeosigan:/media# du -hs hdd2/
63G     hdd2/
root@Gugeosigan:/media# du -hs hdd3/
738G    hdd3/


서버 rsync 백업 디렉토리별 용량


root@Gugeosigan:/media/hdd2# ls
backup  bckup  server
root@Gugeosigan:/media/hdd2# du -hs server
34G     server

root@Gugeosigan:/media/hdd2/server# du -hs bin
7.4M    bin
root@Gugeosigan:/media/hdd2/server# du -hs boot
112M    boot
root@Gugeosigan:/media/hdd2/server# du -hs etc
5.0M    etc
root@Gugeosigan:/media/hdd2/server# du -hs home
30G     home
root@Gugeosigan:/media/hdd2/server# du -hs lib
783M    lib
root@Gugeosigan:/media/hdd2/server# du -hs opt
0       opt
root@Gugeosigan:/media/hdd2/server# du -hs root
65K     root
root@Gugeosigan:/media/hdd2/server# du -hs sbin
6.9M    sbin
root@Gugeosigan:/media/hdd2/server# du -hs srv
0       srv
root@Gugeosigan:/media/hdd2/server# du -hs sys
3.2M    sys
root@Gugeosigan:/media/hdd2/server# du -hs usr
1.2G    usr
root@Gugeosigan:/media/hdd2/server# du -hs var
1.5G    var


root@Gugeosigan:/media/hdd2/server/home/mogibu/www# ls -al
total 326
drwxrwxrwx 1 root root  4096 Apr 11 11:39 .
drwxrwxrwx 1 root root  4096 Apr 12 10:00 ..
-rwxrwxrwx 1 root root  8024 Dec 11 12:03 .htaccess
-rwxrwxrwx 1 root root   393 Dec 11 11:43 .htaccess_orign
drwxrwxrwx 1 root root  8192 Apr  8 09:00 gnuboard
-rwxrwxrwx 1 root root   405 Feb  6  2020 index.php
-rwxrwxrwx 1 root root 19915 Apr 10 08:53 license.txt
-rwxrwxrwx 1 root root  7401 Apr 10 08:53 readme.html
-rwxrwxrwx 1 root root  7387 Apr  3 15:45 wp-activate.php
drwxrwxrwx 1 root root 24576 Apr  2 11:21 wp-admin
-rwxrwxrwx 1 root root   351 Feb  6  2020 wp-blog-header.php
-rwxrwxrwx 1 root root  2323 Jun 14  2023 wp-comments-post.php
-rwxrwxrwx 1 root root  3012 Apr  3 15:45 wp-config-sample.php
-rwxrwxrwx 1 root root  3428 Apr  6 10:56 wp-config.php
-rwxrwxrwx 1 root root     0 Apr  6 11:57 wp-config_new.php
-rwxrwxrwx 1 root root  3384 Dec 11 12:03 wp-config_old.php
drwxrwxrwx 1 root root  4096 Apr 14 07:52 wp-content
-rwxrwxrwx 1 root root  5638 May 31  2023 wp-cron.php
drwxrwxrwx 1 root root 65536 Apr  3 15:45 wp-includes
-rwxrwxrwx 1 root root  2502 Nov 27  2022 wp-links-opml.php
-rwxrwxrwx 1 root root  3927 Jul 16  2023 wp-load.php
-rwxrwxrwx 1 root root 50917 Apr  3 15:45 wp-login.php
-rwxrwxrwx 1 root root  8525 Nov 22 15:19 wp-mail.php
-rwxrwxrwx 1 root root 28427 Apr  3 15:45 wp-settings.php
-rwxrwxrwx 1 root root 34385 Jun 20  2023 wp-signup.php
-rwxrwxrwx 1 root root  4885 Jun 22  2023 wp-trackback.php
-rwxrwxrwx 1 root root  3246 Apr  3 15:45 xmlrpc.php
root@Gugeosigan:/media/hdd2/server/home/mogibu/www# du -hs gnuboard
2.9G    gnuboard
root@Gugeosigan:/media/hdd2/server/home/mogibu/www# du -hs wp-admin
9.8M    wp-admin
root@Gugeosigan:/media/hdd2/server/home/mogibu/www# du -hs wp-content
27G     wp-content
root@Gugeosigan:/media/hdd2/server/home/mogibu/www# du -hs wp-includes
51M     wp-includes

서버 DB Tar, mysqldump 이용 백업 용량


root@Gugeosigan:/media/hdd2/bckup# ls -al
total 1758712
drwxrwxrwx 1 root root       4096 Apr 14 23:00 .
drwxrwxrwx 1 root root       4096 Apr 14 10:03 ..
-rwxrwxrwx 1 root root     568057 Apr 14 09:14 gnuboard.20240414091447.sql
-rwxrwxrwx 1 root root     568057 Apr 14 09:17 gnuboard.20240414091743.sql
-rwxrwxrwx 1 root root     568294 Apr 14 09:29 gnuboard.20240414092905.sql
-rwxrwxrwx 1 root root     589524 Apr 14 23:00 gnuboard.20240414230036.sql
-rwxrwxrwx 1 root root 1274868971 Apr 14 09:28 mogibu_all.20240414092151.tgz
-rwxrwxrwx 1 root root   88619087 Apr 14 09:14 mogibu_wp.20240414091438.sql
-rwxrwxrwx 1 root root   88619087 Apr 14 09:17 mogibu_wp.20240414091735.sql
-rwxrwxrwx 1 root root   88619087 Apr 14 09:29 mogibu_wp.20240414092857.sql
-rwxrwxrwx 1 root root   88674921 Apr 14 23:00 mogibu_wp.20240414230026.sql
-rwxrwxrwx 1 root root   42140098 Apr 14 09:14 var-lib-mysql.20240414091414.tgz
-rwxrwxrwx 1 root root   42134097 Apr 14 09:17 var-lib-mysql.20240414091710.tgz
-rwxrwxrwx 1 root root   42145309 Apr 14 09:28 var-lib-mysql.20240414092831.tgz
-rwxrwxrwx 1 root root   42770710 Apr 14 23:00 var-lib-mysql.20240414230002.tgz

매일 밤 11시 tar, mysqldump DB 백업 / 11시 20분 rsync 백업


root@Gugeosigan : /# crontab -l
# m h  dom mon dow   command
MAILTO = ""
0 12 2 * * /usr/bin/letsencrypt renew >> /var/log/le-renew.log
5 12 2 * * /usr/sbin/service apache2 reload
0 23 * * * /root/bckup.sh 1>/dev/null 2>/dev/null
15 23 * * * /root/rsync.sh
30 23 * * * /sbin/poweroff

root@Gugeosigan:/# cat /root/bckup.sh
#!/bin/bash
tar cvpzf  /media/hdd2/bckup/mogibu_all.`date +%Y%m%d%H%M%S`.tgz --exclude=/bckup --exclude=/proc --exclude=/lost+found --exclude=/media --exclude=/mnt --exclude=/run --exclude=/var/run --exclude=/dev --exclude=/tmp --exclude=/sys --exclude=/var/lib/mysql --exclude=/home / 1>/dev/null 2>/dev/null
tar cvpzf  /media/hdd2/bckup/var-lib-mysql.`date +%Y%m%d%H%M%S`.tgz /var/lib/mysql
mysqldump --login-path=root --extended-insert=FALSE -hlocalhost mogibu_wp > /media/hdd2/bckup/mogibu_wp.`date +%Y%m%d%H%M%S`.sql
mysqldump --login-path=root --extended-insert=FALSE -hlocalhost gnuboard > /media/hdd2/bckup/gnuboard.`date +%Y%m%d%H%M%S`.sql
find /media/hdd2/bckup/ -type f -mtime +10 | sort | xargs rm -f

root@Gugeosigan:/# cat /root/rsync.sh
#!/bin/bash
rsync -au --exclude-from='exclude-file.txt' / /media/hdd2/server

root@Gugeosigan:/# cat /root/exclude-file.txt
/bckup
/proc
/lost+found
/media
/mnt
/run
/var/run
/dev
/tmp
/sys
#/var/lib/mysql