2 # Filename: dirvish-setup
3 # Purpose: create basic setup for dirvish(8)
4 # Authors: grml-team (grml.org), (c) Michael Prokop <mika@grml.org>
5 # Bug-Reports: see http://grml.org/bugs/
6 # License: This file is licensed under the GPL v2.
7 # Latest change: Fre Mär 09 19:45:57 CET 2007 [mika]
8 ################################################################################
10 # http://apt-get.dk/howto/backup/
11 # http://edseek.com/~jasonb/articles/dirvish_backup/advanced.html
12 # http://www.dirvish.org/svn/contrib/admin/DailyEmailScript/dirvish-status.sh
13 ################################################################################
17 . /etc/grml/script-functions
18 . /etc/grml/lsb-functions
21 check4progs dirvish rsync ssh-keygen ssh-copy-id
24 CONFFILE=/etc/dirvish/master.conf
26 # make sure we don't lose any files
27 if [ -f "$CONFFILE" ] ; then
28 mv $CONFFILE $CONFFILE.$(date +%Y%m%d).$$
34 cat > $CONFFILE << EOF
35 # Configuration file for dirvish, created by $PN on $(date)
45 # var/cache/apt/archives
51 # .firefox/default/*/Cache/*
56 # See http://www.dirvish.org/debian.howto.html for further details:
57 expire-default: +30 days
59 # MIN HR DOM MON DOW STRFTIME_FMT
64 # * * * * 2-7 +15 days
71 test -f ~/.keychain/`uname -n`-sh && source ~/.keychain/`uname -n`-sh
75 # prompt user for directory which should be used
76 BACKUP_DIR="$(dialog --stdout --inputbox 'Please choose the directory where backups should be placed' 0 0 /backups)"
78 if ! [ -d "$BACKUP_DIR" ] ; then
79 dialog --stdout --title "${PN}" --yesno "The directory $BACKUP_DIR does not yet exist. Do you want me to create it for you? " 0 0
82 echo "mkdir $BACKUP_DIR"
83 echo "chmod 700 $BACKUP_DIR"
85 echo "warning: $BACKUP_DIR does not exist, skipped creation as requested"
91 CLIENT="$(dialog --stdout --inputbox 'Please choose the name for your client instance, also known as vault' 0 0 client1)"
95 TREE="$(dialog --stdout --inputbox 'Please choose the directory you want to backup from your client (also known as tree)' 0 0 /home)"
98 create_client_conf() {
99 mkdir -p "${BACKUP_DIR}/${CLIENT}/dirvish"
100 if [ -f "${BACKUP_DIR}/${CLIENT}/dirvish/default.conf" ] ; then
101 ewarn "Warning: ${BACKUP_DIR}/${CLIENT}/dirvish/default.conf exists already, ignoring creation." ; eend 0
103 cat > "${BACKUP_DIR}/${CLIENT}/dirvish/default.conf" << EOF
104 # Configuration file of client-side for dirvish created by $PN on $(date)
109 image-default: %Y-%m-%d
111 var/cache/apt/archives/*
115 rsh: ssh -i $HOME/.ssh/id_rsa_dirvish_${CLIENT}
121 CLIENTNAME="$(dialog --stdout --inputbox 'Please choose user login and hostname for the client you want to backup. Syntax: user@host' 0 0 root@$(hostname))"
123 dialog --stdout --title "${PN}" --yesno "Do you want me to create ssh setup for client ${CLIENTNAME} using ssh-keygen and ssh-copy-id?" 0 0
125 if [ $? -eq 0 ]; then
126 [ -d "$HOME/.ssh" ] || mkdir "$HOME/.ssh"
127 einfo "Creating $HOME/.ssh/id_rsa_dirvish_${CLIENT} using ssh-keygen:"
128 ssh-keygen -t rsa -f "$HOME/.ssh/id_rsa_dirvish_${CLIENT}" ; eend $?
129 einfo "Running ssh-copy-id to copy ssh key to $CLIENTNAME:"
130 ssh-copy-id -i "$HOME/.ssh/id_rsa_dirvish_${CLIENT}.pub" $CLIENTNAME ; eend $?
135 dialog --stdout --title "${PN}" --yesno "Do you want to backup $CLIENT via network? Answering with no will use localhost [$(hostname)] as client." 0 0
137 if [ $? -eq 0 ]; then
140 CLIENTNAME=$(hostname) # use localhost only
145 einfo "Running $PN was successful. Enjoy using dirvish!" ; eend 0
147 einfo "Please adjust ${BACKUP_DIR}/${CLIENT}/dirvish/default.conf according to your needs.
148 Then run the following command to create an initial backup:
150 dirvish --summary long --vault $CLIENT --init
152 Find the backup inside $BACKUP_DIR/$CLIENT/$(date +%Y-%m-%d)/tree/ then.
154 Documentation available at:
156 man dirvish-locate.1 dirvish.conf.5 dirvish.8 dirvish-runall.8 dirvish-expire.8
157 /usr/share/doc/dirvish/HOWTO.upstream /usr/share/doc/dirvish/FAQ.html
158 /usr/share/doc/dirvish/HOWTO.Debian.gz
160 http://www.dirvish.org/
161 http://wiki.dirvish.org/
163 Please report bugs regarding ${PN}: http://grml.org/bugs/
169 echo "Usage: $PN" 1>&2
174 # now run the funtions:
179 create_client_conf && \
183 ## END OF FILE #################################################################
184 # vim: ft=sh ai tw=80 expandtab