         async.series([
             (cb) =>
                 dbg("connect to database")
-                require('smc-hub/rethink').rethinkdb
-                    hosts : DB
-                    pool  : 10
-                    cb    : (err, database) =>
-                        @_database = database
-                        cb(err)
+                get_db (err, db) =>
+                    @_database = db
+                    cb(err)
             (cb) =>
                 dbg("create synchronized table")
-                # Get every project that has done a storage request recently
+                # TODO: Get every project that has done a storage request recently
                 age   = misc.minutes_ago(@_age_m)
                 FIELDS   = ['project_id', 'storage_request', 'storage', 'host', 'state']
                 database = @_database

NOTES:
  - save_BUP always saves to GCS as well, so there is no save_GCS.
###

BUCKET = 'smc-projects-bup'  # if given, will upload there using gsutil rsync
DB = ['db0', 'db1', 'db2', 'db3', 'db4', 'db5']  # default database nodes

#if process.env.USER != 'root'
#    console.warn("WARNING: many functions in storage.coffee will not work if you aren't root!")

{join}      = require('path')
fs          = require('fs')

misc        = require('smc-util/misc')
{defaults, required} = misc

postgres = require('./postgres')

# Set the log level
winston.remove(winston.transports.Console)
winston.add(winston.transports.Console, {level: 'debug', timestamp:true, colorize:true})

exclude = () ->
    return ("--exclude=#{x}" for x in misc.split('.sage/cache .sage/temp .trash .Trash .sagemathcloud .smc .node-gyp .cache .forever .snapshots *.sage-backup'))

get_db = (cb) ->
    db = postgres.db()
    db.connect(cb : (err) => cb?(err, db))

# Low level function that save all changed files from a compute VM to a local path.
# This must be run as root.
