[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 624
  • Last Modified:

BackupNinja doesn't work

Hello,

I intalled Backup Ninja, I put a configuration file in /etc/backup.d directory as follows and it didn't do anything.

when = everyday at 01

databases   = all
backupdir   = /var/backups/mysql
hotcopy     = no
sqldump     = yes
compress    = yes

dbusername  = backup_ninja
dbpassword  = GD23ZSAPRuZSFZfU
dbhost = localhost
databases = all
backupdir = /var/backups/mysql



### authentication ###

# three authentication methods:
#
# 1. setting the user, so that /home/user/.my.cnf is used.
# user = some-unix-user
#
# 2. specifying the mysql dbuser and dbpassword,
#    which generates a temporary .my.cnf in /root/.my.cnf
# dbusername  = <some-mysql-user>
# dbpassword  = <password>
#
# 3. specify which config file to use with configfile
#    (this option does not work with hotcopy)
# configfile = /etc/mysql/debian.cnf
#
# if user and dbusername are not specified, the default is to use
# /etc/mysql/debian.cnf for configfile.


### all options ###

# configfile = < path/to/file > (default = /etc/mysql/debian.cnf)
# The config file is passed to mysql with --defaults-file.
# On debian, this default will allow backupninja to make backups
# of mysql without configuring any additional options. 
# (this option is not compatible with "user" or "dbusername").
#
# user = <user> (default = root)
# Run mysql commands as 'user'. A valid .my.cnf must exist with a 
# database username and password in the user's home directory.
# (this option is not compatible with "configfile" or "dbusername").
#
# dbusername = <dbuser> (no default)
# The user must have access to the databases specified later.
# (this option is not compatible with "configfile" or "user").
#
# dbpassword = <dbpass> (no default)
# The password used with dbusername. this password will NOT be passed 
# on the command line and is not readable using "ps aux".
#
# dbhost = <host> (default = localhost)
# only localhost works right now.
#
# databases = < all | db1 db2 db3 > (default = all)
# which databases to backup. should either be the word 'all' or a 
# space separated list of database names.
#
# nodata = < db.table1 db.table2 db.table3 > (no default)
# only dump the structure for the database tables listed here, this means
# no data contained in these tables will be dumped. This is very useful
# to backup databases that have tables with large amounts of cache data that
# isn't necessary to backup, but you still need the structure to exist
# on a restore. You *must* specify the table as part of a database, such
# as "drupal.cache", where the database name is "drupal" and the table that
# you do not want to dump the data for is called "cache". 
#
# backupdir = < path/to/destination > (default = /var/backups/mysql)
# where to dump the backups. hotcopy backups will be in a subdirectory 
# 'hotcopy' and sqldump backups will be in a subdirectory 'sqldump'
#
# hotcopy = < yes | no > (default = no)
# make a backup of the actual database binary files using mysqlhotcopy.
#
# sqldump = < yes | no > (default = no)
# make a backup using mysqldump. this creates text files with sql commands
# sufficient to recontruct the database.
#
# sqldumpoptions = <options>
# (default = --lock-tables --complete-insert --add-drop-table --quick --quote-names)
# arguments to pass to mysqldump
#
# compress = < yes | no > (default = yes)
# if yes, compress the sqldump output. 
#
# vsname = <vserver> (no default)
# what vserver to operate on (only used if vserver = yes 
# in /etc/backupninja.conf), if you do not specify a vsname the 
# host will be operated on
# 
# NB: databases = all doesn't seem to work with hotcopy = yes 
# when vsname is specified, I would like to know how to fix this.

Open in new window


I am a newbie - maybe cron or backup ninja is not running?

Thank you
0
starhu
Asked:
starhu
  • 9
  • 9
1 Solution
 
starhuAuthor Commented:
No answer?
0
 
nociSoftware EngineerCommented:
It most probably does some logging
Default is in:
/var/lib/log/backupninja.log

but maybe in:
/var/log?

You can find log settings  with:
grep logfile /etc/backupninja.conf

0
 
nociSoftware EngineerCommented:
(and yes cron needs to be started, the /etc/cron.d is a place to drop the ninja backup startup into.) [ should be done by install script ]
0
Transaction-level recovery for Oracle database

Veeam Explore for Oracle delivers low RTOs and RPOs with agentless transaction log backup and transaction-level recovery of Oracle databases. You can restore the database to a precise point in time, even to a specific transaction.

 
starhuAuthor Commented:
The log says:

 
Oct 07 01:00:01 Info: >>>> starting action /etc/backup.d/action.mysql (because it is everyday at 01)       
 Oct 07 01:00:01 Fatal: Backup directory '/var/backups/mysql                                                
 /var/backups/mysql'                                                                                        
 Oct 07 01:00:01 Fatal: <<<< finished action /etc/backup.d/action.mysql: FAILED                             
 Oct 07 01:00:02 Info: FINISHED: 1 actions run. 1 fatal. 0 error. 0 warning.

Open in new window


The '/var/backups/mysql exists. Can it be a problem that in the action.mysql the line "backupdir   = /var/backups/mysql " was twice accidentally?                                              
0
 
nociSoftware EngineerCommented:
So it did something,
I wouldn't expect that, but by all means remove the doubles. (also the databases).

Also you may need to update the GZIP_OPTS as not all gzip 's support the default --resyncable
-q (quiet) is an acceptable alternative.
0
 
starhuAuthor Commented:
Hello,

I removed the duplicate, BackupNinja did the work according to the log:

 
Oct 08 01:00:01 Info: >>>> starting action /etc/backup.d/action.mysql (because it is everyday at 1)                                                                                                            
Oct 08 01:00:01 Info: Initializing SQL dump method                                                                                                                                                             
Oct 08 01:00:01 Info: Successfully finished dump of mysql database all                                                                                                                                         
Oct 08 01:00:01 Info: Successfully finished dump of mysql database all                                                                                                                                         
Oct 08 01:00:02 Info: <<<< finished action /etc/backup.d/action.mysql: SUCCESS                                                                                                                                 
Oct 08 01:00:02 Info: FINISHED: 1 actions run. 0 fatal. 0 error. 0 warning.

Open in new window


But it doesn't seem to export the data, the var/backups/mysql/sqldump contains a file named all.sql.gz that contains this:

-- MySQL dump10.13  Distrib 5.1.41, for debian-linux-gnu (x86_64)                                                                                                                                            
--                                                                                                                                                                                                            
-- Host: localhost    Database: all                                                                                                                                                                            
-- ------------------------------------------------------                                                                                                                                                      
-- Server version<----->5.1.41-3ubuntu12.10                                                                                                                                                                    

/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;                                                                                                                                              
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;                                                                                                                                            
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;                                                                                                                                              
/*!40101 SET NAMES utf8 */;                                                                                                                                                                                    
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;                                                                                                                                                                    
/*!40103 SET TIME_ZONE='+00:00' */;                                                                                                                                                                            
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;                                                                                                                                          
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;                                                                                                                            
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;                                                                                                                                    
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;                                                                                                                                                      


0
 
nociSoftware EngineerCommented:
What version are you using?
I have: 0.9.9  - latest available is 0.9.10 though.
In the configured directory backup directory i have a sqldump subdirectory with an tar file Per database i have.

And the content should be just behind the data you have just shown, thats the preamble of an sql dump.
Any errors in the log maybe?

0
 
starhuAuthor Commented:
I should have the latest (I don't know how to check it) because I downloaded 1 week ago.

Can you post your Mysql Backup configuration file? I would try with that if you don't mind.

There were not errors. The only thing I might mention is that I edited the file on my Pc then I uploaded the mysql config file to Linux.

Thank you
0
 
nociSoftware EngineerCommented:
when = everyday at 01
### backupninja MySQL config file ###

# hotcopy = < yes | no > (default = no)
# make a backup of the actual database binary files using mysqlhotcopy.
hotcopy = no

# sqldump = < yes | no > (default = no)
# make a backup using mysqldump. this creates text files with sql commands
# sufficient to recontruct the database.
#
sqldump = yes

# sqldumpoptions = <options>
# (default = --lock-tables --complete-insert --add-drop-table --quick --quote-names)
# arguments to pass to mysqldump
# sqldumpoptions = --add-drop-table --quick --quote-names

# compress = < yes | no > (default = yes)
# if yes, compress the sqldump output.
#compress = yes

# dbhost      = <host> (default = localhost)


# backupdir = <dir> (default: /var/backups/mysql)
# where to dump the backups. hotcopy backups will be in a subdirectory
# 'hotcopy' and sqldump backups will be in a subdirectory 'sqldump'
backupdir = /store/backup/ninja/

# databases = <all | db1 db2 db3 > (default = all)
# which databases to backup. should either be the word 'all' or a
# space separated list of database names.
databases = all
dbhost = localhost
dbusername = backupaccount
dbpassword = guessyouwanttoknowthis
0
 
starhuAuthor Commented:
Hello,

I will try your settings. What rights did you set for the mysql user?
0
 
nociSoftware EngineerCommented:
create user backup@localhost identified by 'somepassword' ;
grant lock tables, select, process on *.* to backup@localhost ;
0
 
starhuAuthor Commented:
The PROCESS wasn't set. I set it, tomorrow I will see the result.
0
 
nociSoftware EngineerCommented:
You are aware of the backupninja --now command?
0
 
nociSoftware EngineerCommented:
(Ow do that from an empty directory, i saw something weird doing that it exanded the * in /* & */...
)
0
 
starhuAuthor Commented:
Hello,

What

So with your backup file the result is the same.

The log reads:
 Oct 12 01:00:02 Info: >>>> starting action /etc/backup.d/action.mysql (because i
 Oct 12 01:00:02 Info: Initializing SQL dump method                              
 Oct 12 01:00:02 Info: Successfully finished dump of mysql database all          
 Oct 12 01:00:02 Info: Successfully finished dump of mysql database all
 Oct 12 01:00:02 Info: <<<< finished action /etc/backup.d/action.mysql: SUCCESS  
 Oct 12 01:00:02 Info: FINISHED: 1 actions run. 0 fatal. 0 error. 0 warning.  

but in the directory: there is only a all.sql.gz file with the following:

 -- MySQL dump 10.13  Distrib 5.1.41, for debian-linux-gnu (x86_64)              
 --                                                                              
 -- Host: localhost    Database: all                                            
 -- ------------------------------------------------------                      
 -- Server version<----->5.1.41-3ubuntu12.10                                    

 /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;              
 /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;            
 /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;              
 /*!40101 SET NAMES utf8 */;                                                    
 /*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;                                    
 /*!40103 SET TIME_ZONE='+00:00' */;                                            
 /*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;            
 /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0
 /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;    
 /*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;                        

I am sure this should be something trivial I missed

Thank you



0
 
nociSoftware EngineerCommented:
You also have databases = all lines twice in your profile (original)
You have two lines...

My guess you try to literary backup a database named all because
you try to backup "all all "

Apparently backupninja hates double config lines.

(Normally you cannot create a database named all)
0
 
starhuAuthor Commented:

strange, the action.mysql is:

 
when = everyday at 01                                                                                                                                                                                          
hotcopy     = no                                                                                                                                                                                               
sqldump     = yes                                                                                                                                                                                              
backupdir   = /var/backups/mysql/ninja/                                                                                                                                                                        
databases   = all                                                                                                                                                                                              
# compress    = yes....................                                                                                                                                                                        
databases = all                                                                                                                                                                                                
dbhost = localhost                                                                                                                                                                                             
dbusername  = backup_ninja                                                                                                                                                                                     
dbpassword  = MyPassword

Open in new window


my backupninja.conf is:

 
reportspace = yes                                                                                                                                                                                       

# where to rsync the backupninja.log to be aggregated in                                                                                                                                                       
# a ninjareport                                                                                                                                                                                                
reporthost =.                                                                                                                                                                                                  

# what user to connect to reporthost to sync the                                                                                                                                                               
# backupninja.log                                                                                                                                                                                              
reportuser = ninja                                                                                                                                                                                             

# where on the reporthost should the report go                                                                                                                                                                 
# NOTE: the name of the log will be used in the report,.                                                                                                                                                       
# use a globally unique name, preferably the hostname                                                                                                                                                          
reportdirectory = /var/lib/backupninja/reports                                                                                                                                                                 

# set to the administration group that is allowed to.                                                                                                                                                          
# read/write configuration files in /etc/backup.d                                                                                                                                                              
admingroup = root                                                                                                                                                                                              

#######################################################                                                                                                                                                        
# for most installations, the defaults below are good #                                                                                                                                                        
#######################################################                                                                                                                                                        

# where to log:                                                                                                                                                                                                
logfile = /var/log/backupninja.log                                                                                                                                                                             

# directory where all the backup configuration files live                                                                                                                                                      
configdirectory = /etc/backup.d                                                                                                                                                                                

# where backupninja helper scripts are found                                                                                                                                                                   
scriptdirectory = /usr/share/backupninja                                                                                                                                                                       

# where backupninja libs are found                                                                                                                                                                             
libdirectory = /usr/lib/backupninja                                                                                                                                                                            

# whether to use colors in the log file                                                                                                                                                                        
usecolors = yes                                                                                                                                                                                                

# default value for 'when'                                                                                                                                                                                     
when = everyday at 01:00                                                                                                                                                                                       

# if running vservers, set to yes                                                                                                                                                                              
vservers = no                                                                                                                                                                                                  

# programs paths                                                                                                                                                                                               
# SLAPCAT=/usr/sbin/slapcat                                                                                                                                                                                    
# LDAPSEARCH=/usr/bin/ldapsearch                                                                                                                                                                               
# RDIFFBACKUP=/usr/bin/rdiff-backup                                                                                                                                                                            
# CSTREAM=/usr/bin/cstream                                                                                                                                                                                     
# MYSQL=/usr/bin/mysql                                                                                                                                                                                         
# MYSQLHOTCOPY=/usr/bin/mysqlhotcopy                                                                                                                                                                           
# MYSQLDUMP=/usr/bin/mysqldump                                                                                                                                                                                 
# PGSQLDUMP=/usr/bin/pg_dump                                                                                                                                                                                   
# PGSQLDUMPALL=/usr/bin/pg_dumpall                                                                                                                                                                             
# GZIP=/bin/gzip                                                                                                                                                                                               
# RSYNC=/usr/bin/rsync                                                                                                                                                                                         
# VSERVERINFO=/usr/sbin/vserver-info                                                                                                                                                                           
# VSERVER=/usr/sbin/vserver                                                                                                                                                                                    
# VROOTDIR=/var/lib/vservers

Open in new window

0
 
starhuAuthor Commented:
You were right: the doubled line caused the problem
0

Featured Post

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

  • 9
  • 9
Tackle projects and never again get stuck behind a technical roadblock.
Join Now