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 /