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 ################################################################################
9 # http://apt-get.dk/howto/backup/
10 # http://edseek.com/~jasonb/articles/dirvish_backup/advanced.html
11 # http://www.dirvish.org/svn/contrib/admin/DailyEmailScript/dirvish-status.sh
12 ################################################################################
16 . /etc/grml/script-functions
17 . /etc/grml/lsb-functions
20 check4progs dialog dirvish rsync ssh-keygen ssh-copy-id
23 CONFFILE=/etc/dirvish/master.conf
28 if [ -f "$CONFFILE" ] ; then
29 MASTERINFO="Notice: $CONFFILE exists already so I will not touch it.
30 Please do not forget to add $CLIENT to the file if you wan to use the 'Runall' functionality."
32 MASTERINFO="An initial master configuration ($CONFFILE) has been generated.
33 Please adjust it according to your needs."
34 cat > $CONFFILE << EOF
35 # Master configuration file for dirvish, created by $PN on $(date)
46 # var/cache/apt/archives
52 # .firefox/default/*/Cache/*
56 # add-another-client-here 22:00
58 # See http://www.dirvish.org/debian.howto.html for further details:
59 expire-default: +30 days
61 # MIN HR DOM MON DOW STRFTIME_FMT
66 # * * * * 2-7 +15 days
74 test -f ~/.keychain/`uname -n`-sh && . ~/.keychain/`uname -n`-sh
78 # prompt user for directory which should be used
79 BACKUP_DIR="$(dialog --stdout --inputbox 'Please choose the directory where backups should be placed' 0 0 /backups)"
81 if ! [ -d "$BACKUP_DIR" ] ; then
82 dialog --stdout --title "${PN}" --yesno "The directory $BACKUP_DIR does not yet exist. Do you want me to create it for you? " 0 0
85 echo "mkdir $BACKUP_DIR"
86 echo "chmod 700 $BACKUP_DIR"
88 echo "warning: $BACKUP_DIR does not exist, skipped creation as requested"
94 CLIENT="$(dialog --stdout --inputbox 'Please choose the name for your client instance, also known as vault' 0 0 client1)"
98 TREE="$(dialog --stdout --inputbox 'Please choose the directory you want to backup from your client (also known as tree)' 0 0 /home)"
101 create_client_conf() {
102 mkdir -p "${BACKUP_DIR}/${CLIENT}/dirvish"
103 if [ -f "${BACKUP_DIR}/${CLIENT}/dirvish/default.conf" ] ; then
104 ewarn "Warning: ${BACKUP_DIR}/${CLIENT}/dirvish/default.conf exists already, ignoring creation." ; eend 0
106 cat > "${BACKUP_DIR}/${CLIENT}/dirvish/default.conf" << EOF
107 # Configuration file of client-side for dirvish created by $PN on $(date)
112 image-default: %Y-%m-%d
114 var/cache/apt/archives/*
118 rsh: ssh -i $HOME/.ssh/id_rsa_dirvish_${CLIENT}
124 CLIENTNAME="$(dialog --stdout --inputbox 'Please choose user login and hostname for the client you want to backup. Syntax: user@host' 0 0 root@$(hostname))"
126 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
128 if [ $? -eq 0 ]; then
129 [ -d "$HOME/.ssh" ] || mkdir "$HOME/.ssh"
130 einfo "Creating $HOME/.ssh/id_rsa_dirvish_${CLIENT} using ssh-keygen:"
131 ssh-keygen -t rsa -f "$HOME/.ssh/id_rsa_dirvish_${CLIENT}" ; eend $?
132 einfo "Running ssh-copy-id to copy ssh key to $CLIENTNAME:"
133 ssh-copy-id -i "$HOME/.ssh/id_rsa_dirvish_${CLIENT}.pub" $CLIENTNAME ; eend $?
138 dialog --stdout --title "${PN}" --yesno "Do you want to backup $CLIENT via network? Answering with no will use localhost [$(hostname)] as client." 0 0
140 if [ $? -eq 0 ]; then
143 CLIENTNAME=$(hostname) # use localhost only
148 einfo "Running $PN was successful. Enjoy using dirvish!" ; eend 0
150 einfo "Please adjust ${BACKUP_DIR}/${CLIENT}/dirvish/default.conf according to your needs.
152 Then run the following command to create an initial backup:
154 dirvish --summary long --vault $CLIENT --init
156 Find the backup inside $BACKUP_DIR/$CLIENT/$(date +%Y-%m-%d)/tree/ then.
158 Documentation available at:
160 man dirvish-locate.1 dirvish.conf.5 dirvish.8 dirvish-runall.8 dirvish-expire.8
161 /usr/share/doc/dirvish/HOWTO.upstream /usr/share/doc/dirvish/FAQ.html
162 /usr/share/doc/dirvish/HOWTO.Debian.gz
164 http://www.dirvish.org/
165 http://wiki.dirvish.org/
167 Please report bugs regarding ${PN}: http://grml.org/bugs/
173 echo "Usage: $PN" 1>&2
178 # now run the funtions:
183 create_client_conf && \
187 ## END OF FILE #################################################################
188 # vim: ft=sh ai tw=80 expandtab