Configuration File: .mega_scriptsrc

In this Document

Description

General Configuration [MEGA_COMMON]

Configuration for [MEGA_DB_SAVE_UPLOAD]

Configuration for [MEGA_DELETE_OLD]

Configuration for [MEGA_UPLOAD_FILE]

Related

Description

A configuration file is used to manage setting for the Mega Scripts files.

The name of this configuration file is ".mega_scriptsrc".

A new configuration file may be created for each user account that is going to use Mega Scripts.


Once you have installed Mega Scripts you will need to edit just a few configuration settings to get started in the General Configuration.

You may want to set the GPG_OWNER field to the "Real Name" you set when you created your GPG Private/Public key-pair.

You may want to set up your .my.cnf file for MySqldump.

You may want to change SERVER_NAME to the name of your server in the configure section. See Configuration File for instruction on how to set up .mega_scriptsrc configuration file.

That is really all that you need to get started. Of course make sure you have set up .megarc file of some sort.


General Configuration

This table is the possible configuration settings that can go into .mega_scriptsrc for section [MEGA_COMMON].

Key

Required

Description

GPG_OWNER

String Value. The GPG public key owner. See GnuPg Encrypt and Decrypt on how to set GPG public key.

SERVER_NAME

String Value. The name of the current server the script is running on. Used in logs and email.

MEGA_DEL_OLD_NAME

String Value. Default is mega_del_old.sh. This is the default name of mega_del_old.sh and is include for the rare instance that the script would need to be used as a different name.

MEGA_EXIST_FILE_NAME

String Value. Default is mega_dir_file_exist.sh. This is the default name of mega_dir_file_exist.sh and is include for the rare instance that the script would need to be used as a different name.

MEGA_MKDIR_FILE_NAME

String Value. Default is mega_mkdir.sh. This is the default name of mega_mkdir.sh and is include for the rare instance that the script would need to be used as a different name.

MEGA_UPLOAD_FILE_NAME

String Value. Default is mega_upload_file.sh. This is the default name of mega_upload_file.sh and is include for the rare instance that the script would need to be used as a different name.

MT_MEGA_DF

String Value. Default is megadf Variable is the location of megadf of Megatools. This can be a location other then in your path such as MT_MEGA_DF="$HOME"/.local/bin/megadf

This variable is useful if you have installed Megatools in a place that is not part of your $PATH environment. Such may be the case if you build Megatools yourself. There is no need to set this variable if Megatools is in your $PATH environment.

MT_MEGA_MKDIR

String Value. Default is megamkdir Variable is the location of megamkdir of Megatools. This can be a location other then in your path such as MT_MEGA_MKDIR="$HOME"/.local/bin/megamkdir

This variable is useful if you have installed Megatools in a place that is not part of your $PATH environment. Such may be the case if you build Megatools yourself. There is no need to set this variable if Megatools is in your $PATH environment.

MT_MEGA_PUT

String Value. Default is megaput Variable is the location of megaput of Megatools. This can be a location other then in your path such as MT_MEGA_MKDIR="$HOME"/.local/bin/megaput

This variable is useful if you have installed Megatools in a place that is not part of your $PATH environment. Such may be the case if you build Megatools yourself. There is no need to set this variable if Megatools is in your $PATH environment.

MT_MEGA_LS

String Value. Default is megals Variable is the location of megals of Megatools. This can be a location other then in your path such as MT_MEGA_LS="$HOME"/.local/bin/megals

This variable is useful if you have installed Megatools in a place that is not part of your $PATH environment. Such may be the case if you build Megatools yourself. There is no need to set this variable if Megatools is in your $PATH environment.

MT_MEGA_RM

String Value. Default is megarm Variable is the location of megarm of Megatools. This can be a location other then in your path such as MT_MEGA_RM="$HOME"/.local/bin/megarm

This variable is useful if you have installed Megatools in a place that is not part of your $PATH environment. Such may be the case if you build Megatools yourself. There is no need to set this variable if Megatools is in your $PATH environment.


Configuration for [MEGA_DB_SAVE_UPLOAD]

This table is the possible configuration settings that can go into .mega_scriptsrc for section [MEGA_DB_SAVE_UPLOAD].

See mega_db_save_upload.sh

Key

Required

Description

BAK_DIR

String Value. Default is /home/${USER}/tmp. Which is the tmp directory of the user passed in via -u. This is the directory that the backup of the database is created in.

DAYS_TO_KEEP_BACKUP

Integer Value. Default is 60. If this value is set to 0 then all backups for the current database on Mega.nz will be deleted before the current backup is sent.

Can be overridden by -a option of mega_db_save_upload.sh

DB_USER

String Value. Default is root. The MySql database user used to create database dumps with for backup.

DELETE_BZ2_FILE

Boolean Value. Default is true. If true bz2 file of the database dump is deleted after encryption.

DELETE_LOCAL_BACKUP

Boolean Value. Default is true. If true the local backup is deleted after the backup is confirmed to be on Mega.nz.

ENCRYPT_OUTPUT

Boolean Value. Default is true. If true database is encrypted before sending to Mega.nz. See GnuPG Encrypt and Decrypt

LOG

String Value. Default is /home/${USER}/logs/mega_db.log. The path of the log file to output results.

See -u for USER  of mega_db_save_upload.sh

LOG_ID

String Value. Default is MEGA DATABASE:. This is an Id to identify which script made the entry into the log file.

LOG_SEP

String Value. The text that is use to separate log entries from different times.

MEGA_BACKUP_DIR

String Value. Default is /${SERVER_NAME}/backups/${USER}/database.

This is the location that the database backup will be saved on Mega.nz.

See: SERVER_NAME and -n of mega_db_save_upload.sh

MEGA_ENABLED

Boolean Value. Default is true. If true database is sent to Mega.nz.

SEND_EMAIL_FROM

String Value. A valid email address that is used as the From when an email is sent.

SEND_EMAIL_ON_ERROR

Boolean Value. Default is false. If true SEND_EMAIL_TO and SEND_EMAIL_FROM must also be set. Sends an email specified by SEND_EMAIL_TO value if there is an error during the execution of the script. Sendmail must be installed for email to be sent out by this script.
Can be overridden by -m option of mega_db_save_upload.sh

SEND_EMAIL_TO

String Value. A valid email address to send an email to upon an error. If specifying more then one email then separate each email by comma and space. Example: SEND_EMAIL_TO=myemail1@domain.com, myemail2@domain.com, myemail3@otherdomain.com

SYS_LOG

Default is /var/log/mega_db.log. This the path to where system errors are logged if they occur. If your executing this script as a non-root user then this value would need to be set to a directory that the non-root user has write access to.

MYSQL_TEST_DB

Boolean Value. Default is true. If set to false then skips testing for mysql database. If for any reason you know that your database exist and you are getting an error 52 then you can set thei option to false. The option -f of mega_db_save_upload.sh will override this setting.

MYSQL_TEST_CNF

Boolean Value. Default is true. If set to false then skips testing for mysql configuration. If you know that your mysql configuration file is set up properly for mysqldump and your are getting an error 50 then you can set this option to false. The option -f of mega_db_save_upload.sh will override this setting.

TEST_GPG

Boolean Value. Default is true. If set to false then skips testing if gpg public key exist. If for any reason your are getting an error of 117 and you know your public key is imported then you can set this option to false. The option -f of mega_db_save_upload.sh will override this setting.

See GnuPG Encrypt and Decrypt.

TEST_USER

Boolean Value. Default is true. If set to false then skips testing for unix user. Must override ( LOG or use -o option of mega_db_save_upload.sh), BAK_DIR and MEGA_BACKUP_DIR. The option -f of mega_db_save_upload.sh will override this setting.


Configuration for [MEGA_DELETE_OLD]

See Mega_del_old.sh

Key

Required

Description

LOG_ID

String Value. Default is MEGA DELETE OLD:. This is an Id to identify which script made the entry into the log file.

MAX_DAYS_DEFAULT

Integer Value. Default is 60. If this value is set to 0 then all files for the current folder on Mega.nz will be deleted

LOG

String Value. Default is  /var/log/mega_delete_old.log. The name of the log file to output results. If your executing this script as a non-root user then this value would need to be set to a directory that the non-root user has write access to.


Configuration for [MEGA_UPLOAD_FILE]

See mega_upload_file.sh

Key

Required

Description

LOG_ID

String Value. Default is MEGA PUT:. This is an Id to identify which script made the entry into the log file.

LOG

String Value. Default is /var/log/mega_upload_file.log. The name of the log file to output results. If your executing this script as a non-root user then this value would need to be set to a directory that the non-root user has write access to.

Remarks

For encryption you will need to configure GnuPG.

For Database backups you will need to configure server to use MySqlDump.

Example

Example of most basic configuration for .mega_scriptsrc

[MEGA_COMMON]
GPG_OWNER=bbserver
SERVER_NAME=bbserver


Example

Example of configuration file .mega_scriptsrc for non root user bigbyte


[MEGA_COMMON]
GPG_OWNER=bbserver
SERVER_NAME=bbserver

[MEGA_DB_SAVE_UPLOAD]
DB_USER=bigbyte
LOG=/home/bigbyte/logs/mega_db_save_up.log
SYS_LOG=/home/bigbyte/logs/mega_db_save_up_sys.log


Example

Example of configuration file .mega_scriptsrc that has mega_del_old.sh, mega_dir_file_exist.sh, mega_mkdir.sh and mega_upload_file.sh renamed to . (dot) hidden files. This is for configuration is also for a non root user bigbyte; however, the same configuration change would have to be made for all user that share access to the same scripts.


Rename mega_del_old.sh, mega_dir_file_exist.sh, mega_mkdir.sh and mega_upload_file.sh


# mv /usr/local/bin/mega_del_old.sh /usr/local/bin/.mega_del_old.sh
# mv /usr/local/bin/mega_dir_file_exist.sh /usr/local/bin/.mega_dir_file_exist.sh
# mv /usr/local/bin/mega_mkdir.sh /usr/local/bin/.mega_mkdir.sh
# mv /usr/local/bin/mega_upload_file.sh /usr/local/bin/.mega_upload_file.sh



Change the configuration file to represent the new names.


bigbyte@bbserver:~$ nano .mega_scriptsrc


[MEGA_COMMON]
GPG_OWNER=bbserver
SERVER_NAME=bbserver
MEGA_EXIST_FILE_NAME=.mega_dir_file_exist.sh
MEGA_DEL_OLD_NAME=.mega_del_old.sh
MEGA_MKDIR_FILE_NAME=.mega_mkdir.sh
MEGA_UPLOAD_FILE_NAME=.mega_upload_file.sh

[MEGA_DB_SAVE_UPLOAD]
DB_USER=bigbyte
LOG=/home/bigbyte/logs/mega_db_save_up.log
SYS_LOG=/home/bigbyte/logs/mega_db_save_up_sys.log

Example

Example of setting up root user to receive emails for errors executing script mega_db_save_upload.sh


root@bbserver:~# nano .mega_scriptsrc


[MEGA_COMMON]
GPG_OWNER=bbserver
SERVER_NAME=bbserver

[MEGA_DB_SAVE_UPLOAD]
SEND_EMAIL_ON_ERROR=true
SEND_EMAIL_FROM=bbservar@example.com
SEND_EMAIL_TO=admin@example.com

See mega_db_save_upload.sh - Configuration

Related

Getting Started