You are not logged in.
Pages: 1
I like Arch and use it everyday. I always keep my arch updated. Sometimes i worry about hard disk failure. So i want to backup arch.
Any convenient way is appreciated!
e^(π⋅i) + 1 = 0
Offline
Have you looked into rsync and it's mates?
Offline
there are lots of ways to backup your stuff.
Offline
also, if you would like a little more control over your backup check this out
http://wiki.archlinux.org/index.php/Ful … with_rsync
Hofstadter's Law:
It always takes longer than you expect, even when you take into account Hofstadter's Law.
Offline
I use rsync to back up and changes made to /home and /etc onto a second disk upon shutdown. I make hard copies of that stuff on DVDs also.
Offline
I use this script to back up only selected things with rdiff-backup to encrypted removable disk. There's configuration embedded in it to know where to find the disk, and what to back up, for each machine it runs on. Much of it is specific to me, but hopefully it's a nice example.
#!/bin/bash
# vim:set filetype=sh: *
if [ `id -u` != "0" ] ; then
echo "You must be root"
exit 1
fi
case "$(hostname -s)" in
"asenath")
role=primary
diskpart="usb-_Patriot_Memory_07960608B32D3531-0:0-part1"
;;
"akherou")
role=duplicate
diskpart="usb-_Patriot_Memory_07960608B32D3531-0:0-part1"
;;
"amaranth")
role=primary
diskpart="usb-ST375063_0AS_00E001012641D-0:0-part2"
;;
*)
echo -e "\e[31m==> Unable to determine machine role for $(hostname -s)\e[0m"
exit 2
esac
disk="${diskpart%-part*}"
case "$disk" in
"usb-_Patriot_Memory_07960608B32D3531-0:0")
disktype=ssd
disksize=small
;;
"usb-ST375063_0AS_00E001012641D-0:0")
disktype=hdd
disksize=big
;;
*)
echo -e "\e[31m==> Unknown disk ${disk}\e[0m"
exit 3
esac
echo -e "\e[32m==> Backing up with: disksize=${disksize} role=${role}\e[0m"
logger -t backup "backup started"
while [[ ! -b /dev/mapper/lb ]] ; do
while [[ ! -b /dev/disk/by-id/${diskpart} ]] ; do sleep 1 ; done
cryptsetup luksOpen /dev/disk/by-id/${diskpart} lb
done
if [[ $(stat -c "%i" /backup) != "2" ]] ; then
fsck /dev/mapper/lb || exit 4
mount /backup || exit 5
fi
sync
case "$disksize" in
"big")
backuplist="--exclude /home/ataraxia/.cache \
--exclude /home/ataraxia/junk \
--include /boot/grub/menu.lst \
--include /etc \
--include /home \
--include /var/lib/pacman/local \
--include /var/spool/cron \
"
;;
"small")
case "$role" in
"primary")
backuplist="--include /home/ataraxia/pkgs/.hg \
--exclude /home/ataraxia/.cache \
--exclude /home/ataraxia/junk \
--exclude /home/ataraxia/music \
--exclude /home/ataraxia/pkgs \
--exclude /home/ataraxia/.mozilla/firefox/firefox/42y0m9cw.default/extensions/VMwareVMRC@vmware.com \
--exclude /home/ataraxia/.thunderbird/z10luhfe.default/global-messages-db.sqlite \
--exclude /home/ataraxia/.thunderbird/z10luhfe.default/ImapMail \
--include /boot/grub/menu.lst \
--include /etc \
--include /home \
--include /var/lib/pacman/local \
--include /var/spool/cron \
"
;;
"duplicate")
backuplist="--exclude /home/ataraxia/.cache \
--exclude /home/ataraxia/.config/chromium \
--exclude /home/ataraxia/.mozilla \
--exclude /home/ataraxia/.thunderbird \
--exclude /home/ataraxia/code \
--exclude /home/ataraxia/docs \
--exclude /home/ataraxia/junk \
--exclude /home/ataraxia/music \
--exclude /home/ataraxia/pkgs \
--include /boot/grub/menu.lst \
--include /etc \
--include /home \
--include /var/lib/pacman/local \
--include /var/spool/cron \
"
;;
*)
echo -e "\e[31m==> Disksize \"small\" must have role \"primary\" or \"duplicate\", not ${role}\e[0m"
exit 6
esac
;;
*)
echo -e "\e[31m==> Unknown disksize ${disksize}\e[0m"
exit 7
esac
rdiff-backup \
--exclude-sockets \
--exclude-fifos \
$backuplist \
--exclude '**' \
/ \
/backup/$(hostname -s)
sync
rdiff-backup --list-changed-since 1B /backup/$(hostname -s)
df -h /backup
umount /backup
cryptsetup luksClose lb
if [[ "$disktype" == "hdd" ]] ; then
sleep 3
hdparm -Y /dev/disk/by-id/${disk}
fi
logger -t backup "backup finished"
Offline
Got enough yet?
I'll add one more before you're completely saturated.
Every now and then I do full system backups. Have found it to be useful at times. Here's a real basic script using go' 'ole tar. To use, I just chroot from a LiveCD and run it from there.
#!/bin/bash
# full system backup
# Labels for backup name
#PC=${HOSTNAME}
pc=pavilion
distro=arch
type=full
date=`date "+%F"`
backupname=$distro-$type-$date.tar.gz
# Backup destination
backdest=/opt/backup
# Exclude file location
prog=${0##*/} # Program name from filename
bcdir="/home/todd/.bin/root/backup"
exclude_file="$bcdir/$prog-exc.txt"
# Check if chrooted prompt.
echo -n "First chroot from a LiveCD. Are you ready to backup? (y/n): "
read executeback
if [ $executeback = "y" ]; then
tar --exclude-from=$exclude_file -czpvf $backdest/$backupname /
fi
Last edited by Gen2ly (2010-03-10 04:08:32)
Setting Up a Scripting Environment | Proud donor to wikipedia - link
Offline
Real men don't back up...then cry when they lose everything :'(
Offline
#!/bin/bash
### System Backup ##############
# Version 0.5 by Scott Garrett #
# Wintervenom [(at)] gmail.com #
################################
backup_label="Backup"
exclude="/dev/shm/rsync-excludes.rc"
excludes=(
'tmp/*' # Temp files.
'tmp/.*' # Hidden temp files.
'.mozilla/firefox/*/Cache' # Firefox caches...
'cookies.sqlite' # Mozilla-based cookies.
'formhistory.sqlite' # Mozilla-based form history.
'.thumbnails' # Thumbnail cache.
'.recently-used.xbel' # Recent-open history.
'.ccache' # Compiler caches
'sessionstore.js' # Firefox session-saves.
'.gvfs' # GNOME virtual filesystem.
'.local/share/Trash' # XDG trash.
'.local/share/user-places*' # Recent-open history.
'.purple/logs' # Pidgin/Finch logs.
'.cache/Thunar/thumbnailers.cache' # Thumbnailer cache.
'.cache/chromium' # Chrome cache.
'*~' # Backup/temp files.
)
out () {
echo ">> $*"
}
stat_done () {
echo ">> ...done."
}
stat_fail () {
echo ">> ...failed!"
}
if [ $UID != '0' ]; then
echo "Must be executed as root user."
exit 1
fi
out "Mouting backup device ('$backup_label')..."
backup_dev=`readlink -f "/dev/disk/by-label/$backup_label"`
if mount | grep -qF "$backup_dev on"; then
backup_root=`mount | grep -F "$backup_dev on" | cut -d' ' -f3`
echo " - This device seems to already be mounted at '$backup_root'."
echo ' Do you want to use this, instead (y/N)?'
echo -n ' << '
read -n1 confirm
echo
[ "$confirm" != 'y' ] && exit 1
else
backup_root="/mnt/$backup_label"
mkdir -p "$backup_root"
if ! mount -o noatime,user "$backup_dev" "$backup_root"; then
echo ' - Failed to mount device.'
exit 1
fi
echo ' - Device mounted successfully.'
fi
out "Backing up system..."
echo > /tmp/rsync-excludes.rc
for file in ${excludes[@]}; do
echo "$file" >> "$exclude"
done
rsync -axl -h --progress --delete --delete-excluded --exclude-from="$exclude" /{home,usr,opt,var,*bin,lib*,etc,boot,root,srv} "$backup_root/$HOSTNAME"
mkdir -p "$backup_root/$HOSTNAME/"{dev,sys,proc,tmp,mnt,media}
mkdir -p "$backup_root/$HOSTNAME/var/"{tmp,lock}
chmod 1777 "$backup_root/$HOSTNAME/tmp" "$backup_root/$HOSTNAME/var/"{tmp,lock}
stat_done
out "Backing up package list..."
pacman -Qqe | grep -v "$(pacman -Qmq)" > "$backup_root/$HOSTNAME/pacman.list"
pacman -Qmq > "$backup_root/$HOSTNAME/yaourt.list"
stat_done
out "Unmouting backup partition..."
if umount "$backup_dev"; then
rmdir "$backup_root/$HOSTNAME"
rmdir "$backup_root"
else
echo ' - Could not unmount.';
fi
Last edited by Wintervenom (2010-03-11 09:01:29)
Offline
Pages: 1