Exemple #1
0
def pack_files():
    compress_command = 'tar -C {0} -cvzf {1}-{2}.tar.gz {2}.sql'.format(
        config['dump_path'], config['app_name'], config['timestamp'])

    if config['images']:
        compress_command += ' images'

    if config['themes']:
        compress_command += ' themes'
    status = execute_command(compress_command)

    if status.returncode != 0:
        print("state code here %s " % status.returncode)
        error_and_exit(
            '\nError while packing backup files\n\n{0}'.format(
                format_subprocess_error(status)),
            config.get('telegram_user_id'))
Exemple #2
0
def dump_db():
    if config['images'] and config['themes']:
        dump_path = config['images_dir'] if config['images'] else config[
            'themes_dir']
        config['dump_path'] = os.path.normpath(dump_path + '/..')
    else:
        config['dump_path'] = os.getcwd()

    config['dump_file'] = config['dump_path'] + '/{0}.sql'.format(
        config['timestamp'])
    dump_command = ("mysqldump -h{mysql_hostname} -u'{mysql_username}' "
                    "-p'{mysql_password}' {mysql_db_name} > {0}".format(
                        config['dump_file'], **config))
    status = execute_command(dump_command)

    if status.returncode != 0:
        print("state code here %s " % status.returncode)
        error_and_exit(
            '\nError while taking DB dump\n\n{0}'.format(
                format_subprocess_error(status)),
            config.get('telegram_user_id'))