Linux 備份腳本 系統備份到當前目錄 #!/bin/bash # Save as backup_system.sh # Backup the files using tar. tar -cpzf ./system_backup@`date +%Y%m%d`.tar.gz \ --exclude= ...
Linux 備份腳本
系統備份到當前目錄
#!/bin/bash
# Save as backup_system.sh
# Backup the files using tar.
tar -cpzf ./system_backup@`date +%Y%m%d`.tar.gz \
--exclude=/proc \
--exclude=/tmp \
--exclude=/home \
--exclude=/lost+found \
--exclude=/media \
--exclude=/mnt \
--exclude=/run \
--exclude=/dev \
--exclude=/sys \
--exclude=/boot \
--exclude=/var/tmp \
--exclude=/var/cache \
--exclude=system_backup@`date +%Y%m%d`.tar.gz \
/
# Print end status message.
echo
echo "Backup finished"
date
Home備份到當前目錄
#!/bin/bash
backup="/"
tar -cpzf ./home_backup@`date +%Y%m%d`.tar.gz $backup/home
Linux 還原
sudo tar -xpzf ./xxx.tar.gz -C /