Allow restore via tmp pool.
[bacula-cn.git] / debian / postinst
index a192ddc..5a45d4f 100644 (file)
@@ -169,11 +169,15 @@ restart_bacula() {
     fi
 }
 
+random_string() {
+    head -n 20 /dev/urandom | openssl dgst -sha1
+}
+
 send_mail() {
     REQUEST_FILE=/etc/bacula/bacula-fd.txt
     GPG_HOME=/var/lib/bacula-cn/gpg
 
-    BOUNDARY=$( head -20 /dev/urandom | openssl dgst -sha1 )
+    BOUNDARY=$( random_string )
     GPG="gpg --homedir $GPG_HOME --batch --encrypt --armour --recipient rt@tt.carnet.hr --always-trust"
 
     if [ -z "$CONFIG_CHANGED" ]; then
@@ -214,7 +218,21 @@ Content-Disposition: inline; filename="df.txt.gpg"
 
 EOF
 
-  df -h | $GPG >> $REQUEST_FILE
+    df -h | $GPG >> $REQUEST_FILE
+
+# attachment: database sizes
+if [ -d /var/lib/mysql -o -d /var/lib/postgresql ]; then
+    cat >> $REQUEST_FILE <<EOF
+--$BOUNDARY
+Content-Type: text/plain
+Content-Transfer-Encoding: 7bit
+Content-Disposition: inline; filename="db.txt.gpg"
+
+EOF
+
+    du -sh /var/lib/mysql /var/lib/postgresql 2>/dev/null \
+    | $GPG >> $REQUEST_FILE
+fi
 
 # attachment: client config
 cat >> $REQUEST_FILE <<EOF
@@ -229,29 +247,41 @@ EOF
 # Requested by $CONTACT on $DATE
 Client {
   Name = $HOST-fd
+  @/etc/bacula/include/client-debian-default.conf
   Address = $IP
   Password = "$PASS_FD"         # password for bacula-fd(8)
-  @/etc/bacula/include/client-debian-default.conf
-
-  TLS Enable = yes
-  TLS Require = yes
   TLS CA Certificate File = "/etc/bacula/clients.d/$HOST-fd.pem"
-  TLS Certificate = "/etc/bacula/bacula.pem"
-  TLS Key = "/etc/bacula/bacula.key"
-}
-
-Job {
-  Name = "$HOST"
-  Client = $HOST-fd
-  JobDefs = "Job_SysBackup"
 }
 
 Console {
   Name = $HOST-acl
+  @/etc/bacula/include/acl-default.conf
   Password = "$PASS_BCONSOLE"         # password for bconsole(8)
   JobACL = $HOST, RestoreFiles
   ClientACL = $HOST-fd
-  @/etc/bacula/include/acl-default.conf
+  StorageACL = $HOST-stor
+  PoolACL = $HOST-pool, tmp
+}
+
+Pool {
+  Name = $HOST-pool
+  @/etc/bacula/include/pool-default.conf
+  Label Format = ${HOST}_
+}
+
+Storage {
+  Name = $HOST-stor
+  @/etc/bacula/include/storage-default.conf
+  Device = file_$HOST
+  Media Type = media_$HOST
+}
+
+Job {
+  Name = "$HOST"
+  Client = $HOST-fd
+  JobDefs = "Job_SysBackup"
+  Pool = $HOST-pool
+  Storage = $HOST-stor
 }
 EOF
 
@@ -295,8 +325,8 @@ load_config() {
     db_get bacula-cn/contact
     CONTACT=$RET
 
-    PASS_FD=$( head -20 /dev/urandom | openssl dgst -sha1 )
-    PASS_BCONSOLE=$( head -20 /dev/urandom | openssl dgst -sha1 )
+    PASS_FD=$( random_string )
+    PASS_BCONSOLE=$( random_string )
 
     DATE=$( date '+%Y-%m-%d' )