# Documentation to install backup scripts on a machine and setup postfix to allow email reports # 20 Mar 2012 Mike Gore # # Setup Backup scripts for Linux # Assume: the host is called hostname.cs.uwaterloo.ca # and the owner is userid@cs.uwaterloo.ca # This document was designed to be cut and past to the bash command line except for postfix config # Become root sudo bash #Install scripts mkdir /scripts cp testfree backup README.txt /scripts # Copy these files to a directory called /scripts # Copy the this directory to /backups # Install Postfix for email alerts apt-get install postfix # Configure postfix Postfix Configuration -> Ok General type of mail configuration: Internet Site -> Ok System mail name: hostname.cs.uwaterloo.ca -> Ok Root and postmaster mail recipient: Other destinations to accept mail for (blank for none): hostname.cs.uwaterloo.ca, hostname.cs, localhost.cs, localhost -> OK Force synchronous updates on mail queue? No -> OK Local networks: 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128 -> OK Mailbox size limit (bytes): 0 -> OK Local address extension character: * -> OK Internet protocols to use: ipv4 -> OK # Test email by sending a message to your own CS account # CTRL-D will exit after typing a short test message mail your-userid@cs.uwaterloo.ca -s test # Create mount point for backup drive mkdir /backup # Setup a backup drive # Find all of your drives and see if they are partitioned yet fdisk -l # Make sure your backup drive is partitioned and formated # Example: backup drive is /dev/sdb # Assume: for this example we only want a linux partition # Note: In dual boot cases you want two partions windows/linux # Partition the backup disk - only if it has not been done yet fdisk /dev/sdb n p 1 - for start - for end w - write changes q - quit # formatting example: mkfs -t ext4 /dev/sdb1 # update /etc/fstab # use blkid to get list of drives and their UUID values # Note: save the UUID= line of backup partition blkid # Add an entry to /etc/fstab using the your own UUID as reported above # Example: UUID=43829b3e-56a7-44d2-bf25-faca08a1f964 /backup ext4 errors=remount-r o 0 1 # or with the raw device name - not recommended /dev/sdb1 /backup ext4 errors=remount-r o 0 1 # Mount the partition to test it - this mounts all partions listed in /etc/fstab mount -a # Now list the mounted partitions and make sure your backup partition is there mount # Update /etc/crontab to backup root filesystem at midnight and report to userid # We assume that /backup/root is on another file system # We do a freespace test on the target filesystem - in this case /backup # Send report to local cscf-adm user - can be userid@cs.uwaterloo.ca for off host reports 0 0 * * * root /scripts/backup / /backup/root 10000 cscf-adm