Created
June 7, 2014 13:49
-
-
Save abcarroll/15ee12570eec8df8f7d5 to your computer and use it in GitHub Desktop.
Simple BTRFS Incremental
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# A.B. Carroll [email protected] | |
# File location in my setup: | |
# /media/zebra/launch-zebra-backup | |
# chmod +x /media/launch-zebra-backup | |
date > /media/zebra/last-backup.start | |
date >> /media/zebra/all-backup.start | |
rsync -avh --delete --progress /svn-migrate /media/zebra/ | |
rsync -avh --delete --progress --exclude=/apps/php_errors.log /apps /media/zebra/ | |
rsync -avh --delete --progress /home /media/zebra/ | |
rsync -avh --delete --progress /root /media/zebra/ | |
rsync -avh --delete --progress /etc /media/zebra/ | |
rsync -avh --delete --progress /boot /media/zebra/ | |
service mysql stop | |
mkdir -p /media/zebra/var/lib/ | |
rsync -avh --delete --progress /var/lib/mysql /media/zebra/var/lib/ | |
service mysql start | |
service redis-server stop | |
rsync -avh --delete --progress /var/lib/redis /media/zebra/var/lib/ | |
service redis-server start | |
service rabbitmq-server stop | |
rsync -avh --delete --progress /var/lib/rabbitmq /media/zebra/var/lib/ | |
service rabbitmq-server start | |
echo | |
echo Creating incremental snapshot... | |
btrfs subvolume snapshot -r /media/zebra/ /media/zebra/.snap-`date +%Y-%m-%d-%H` | |
date > /media/zebra/last-backup.end | |
date >> /media/zebra/all-backup.end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Example crontab entry, runs every 4 hours | |
# */4 would suffice instead of the comma list of hours, but I prefer | |
# to specify the actual hours instead so I know hwich hours it will run | |
15 0,4,8,12,16,20 * * * /root/launch-zebra-backup |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# A.B. Carroll [email protected] | |
# File location in my setup: | |
# /root/launch-zebra-backup | |
# chmod +x /root/launch-zebra-backup | |
#!/bin/bash | |
if [ -x /media/zebra/backup-rsync ]; then | |
echo "Running backup to zebra ..." | wall && /media/zebra/backup-rsync && echo "Done backing up to zebra ..." | wall | |
else | |
echo "Can't backup to zebra. Zebra is probably not mounted." | wall | |
fi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# A.B. Carroll [email protected] | |
# This is NOT meant to be ran as a script, but an example how to setup a btrfs filesystem in debian/ubuntu | |
# Update to your real device, such as /dev/sdb1 | |
# Run fdisk /dev/sdb to create an empty partition if you haven't already | |
device=/dev/zero | |
# Install btrfs pkg | |
apt-get -y install btrfs | |
# Make the partition | |
mkfs.btrfs -t btrfs ${device} | |
# Get the blkid | |
blkid ${device} | |
# Add the mount in your fstab like below: | |
# Replace the UUID below with the results of 'blkid' above | |
#UUID=YOUR_UUID_HERE /media/zebra/ btrfs ssd,noatime,ssd_spread,discard,compress=zlib 0 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment