summaryrefslogtreecommitdiff
path: root/config/backup.rb
blob: 88edd945b58dd6504287df16a2f2f53acd6a3580 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# encoding: utf-8

require 'inifile'
SYSTEM_ODBC_CONFIGURATION = IniFile.load('/var/lib/freeswitch/.odbc.ini')

Backup::Model.new(:GS5, 'GS5 backup') do
 
  ##
  # Split [Splitter]
  #
  # Split the backup file in to chunks of 2 GB
  # if the backup file size exceeds 2 GB
  #
  # split_into_chunks_of 2048

  ##
  # MySQL [Database]
  #
  database MySQL do |db|
    # To dump all databases, set `db.name = :all` (or leave blank)
    db.name               = SYSTEM_ODBC_CONFIGURATION['gemeinschaft']['DATABASE']
    db.username           = SYSTEM_ODBC_CONFIGURATION['gemeinschaft']['USER']
    db.password           = SYSTEM_ODBC_CONFIGURATION['gemeinschaft']['PASSWORD']
    db.host               = "localhost"
    db.port               = 3306
    db.socket             = "/var/run/mysqld/mysqld.sock"
    db.skip_tables        = ["backup_jobs", "restore_jobs", "fax_thumbnails"]
  end

  ##
  # Faxes
  #
  if File.exists?('/var/opt/gemeinschaft/fax')
    archive :faxes do |archive|
      # Incoming faxes
      #
      Dir.glob("/var/opt/gemeinschaft/fax/in/**/*.pdf").each do |fax_file|
        archive.add(fax_file)
      end
      Dir.glob("/var/opt/gemeinschaft/fax/in/**/*.tiff").each do |fax_file|
        archive.add(fax_file)
      end

      # Outgoing faxes
      #
      Dir.glob("/var/opt/gemeinschaft/fax/out/**/*.pdf").each do |fax_file|
        archive.add(fax_file)
      end
      Dir.glob("/var/opt/gemeinschaft/fax/out/**/*.tiff").each do |fax_file|
        archive.add(fax_file)
      end
    end
  end

  ##
  # Voicemails
  #
  if File.exists?('/var/opt/gemeinschaft/freeswitch/voicemail')
    archive :voicemails do |archive|
      archive.add     '/var/opt/gemeinschaft/freeswitch/voicemail'
    end
  end

  ##
  # Avatars
  #
  if File.exists?('/opt/gemeinschaft/public/uploads/user/image')
    archive :avatars do |archive|
      archive.add     '/opt/gemeinschaft/public/uploads/user/image'
    end  
  end

  ##
  # Local (Copy) [Storage]
  #
  store_with Local do |local|
    local.path       = "/var/backups/"
  end

  ##
  # Gzip [Compressor]
  #
  compress_with Gzip
end