<commit_before>#! /usr/bin/env bash
#
# Copyright (c) 2013 <NAME>.
#
# This program is free software: you can redistribute it and/or modify it under
# the terms of the Apache License as published by the Apache Foundation.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. 
#
# Most recent information about this tool is available in:
# http://blyx.com/alfresco-bart
#
# Latest code available at:
# http://blyx.com/alfresco-bart
#
#########################################################################################
# alfresco-bart: ALFRESCO BACKUP AND RECOVERY TOOL 
# Version 0.2       
#########################################################################################
# ACTION REQUIRED:
# CONFIGURE alfresco-bart in the alfresco-bart.properties file and ALFBRT_PATH
# in this file.
# Copy all files into your ALFRESCO_INSTALLATION_PATH/scripts.
# RUN ./alfresco-bart.sh [backup|recovery|verify|collection|list] 
#########################################################################################
#
# Run backup daily at 5AM
# 0 5 * * * root /path/to/alfresco-bart.sh backup 
#
#########################################################################################

# Load properties
ALFBRT_PATH=/opt/alfresco/scripts

if [ -f ${ALFBRT_PATH}/alfresco-bart.properties ]; then
	. ${ALFBRT_PATH}/alfresco-bart.properties 
else
	echo alfresco-bart.properties file not found, edit $0 and modify ALFBRT_PATH
fi

# Do not let this script run more than once
PROC=`ps axu | grep -v "grep" | grep --count "duplicity"`
if [ $PROC -gt 0 ]; then 
	echo "alfresco-bart.sh or duplicity is already running."
	exit 1
fi

# Command usage menu
usage(){
echo "USAGE:
    `basename $0` <mode> [set] [date <dest>]

Modes:
    backup [set]	runs an incremental backup or a full if first time
    restore [set] [date] [dest]	runs the restore, wizard if no arguments
    verify [set]	verifies the backup
    collection [set]	shows all the backup sets in the archive
    list [set]		lists the files currently backed up in the archive

Sets:
    all		do all backup sets
    index	use index backup set (group) for selected mode
    db		use data base backup set (group) for selected mode
    cs		use content store backup set (group) for selected mode
    files	use rest of files backup set (group) for selected mode"
}

# Checks if encryption is required if not it adds appropiate flag
if [ $ENCRYPTION_ENABLED = "true" ]; then
	export PASSPHRASE
else
	NOENCFLAG="--no-encryption"
fi

# Checks backup type, target selected
case $BACKUPTYPE in
	"s3" ) 
		DEST=${S3FILESYSLOCATION}
		PARAMS="${GLOBAL_DUPLICITY_PARMS} ${S3OPTIONS} ${NOENCFLAG}"
		;;
	"ftp" ) 
		if [ ${FTPS_ENABLE} == 'false' ]; then
   			DEST=ftp://${FTP_USER}:${FTP_PASSWORD}@${FTP_SERVER}:${FTP_PORT}/${FTP_FOLDER}
   			PARAMS="${GLOBAL_DUPLICITY_PARMS} ${NOENCFLAG}"
		else
   			DEST=ftps://${FTP_USER}:${FTP_PASSWORD}@${FTP_SERVER}:${FTP_PORT}/${FTP_FOLDER}
   			PARAMS="${GLOBAL_DUPLICITY_PARMS} ${NOENCFLAG}"
		fi
		;;	
	"scp" )
		DEST=scp://${SCP_USER}@${SCP_SERVER}/${SCP_FOLDER}
		PARAMS="${GLOBAL_DUPLICITY_PARMS} ${NOENCFLAG}"
		;;
	"local" )
		# command sintax is "file:///" but last / is coming from ${LOCAL_BACKUP_FOLDER} variable
		DEST=file://${LOCAL_BACKUP_FOLDER}<commit_msg>Fixes S3 authentication (issue #5: https://github.com/toniblyx/alfresco-backup-and-recovery-tool/issues/5)<commit_after>#! /usr/bin/env bash
#
# Copyright (c) 2013 <NAME>.
#
# This program is free software: you can redistribute it and/or modify it under
# the terms of the Apache License as published by the Apache Foundation.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. 
#
# Most recent information about this tool is available in:
# http://blyx.com/alfresco-bart
#
# Latest code available at:
# http://blyx.com/alfresco-bart
#
#########################################################################################
# alfresco-bart: ALFRESCO BACKUP AND RECOVERY TOOL 
# Version 0.2       
#########################################################################################
# ACTION REQUIRED:
# CONFIGURE alfresco-bart in the alfresco-bart.properties file and ALFBRT_PATH
# in this file.
# Copy all files into your ALFRESCO_INSTALLATION_PATH/scripts.
# RUN ./alfresco-bart.sh [backup|recovery|verify|collection|list] 
#########################################################################################
#
# Run backup daily at 5AM
# 0 5 * * * root /path/to/alfresco-bart.sh backup 
#
#########################################################################################

# Load properties
ALFBRT_PATH=/opt/alfresco/scripts

if [ -f ${ALFBRT_PATH}/alfresco-bart.properties ]; then
	. ${ALFBRT_PATH}/alfresco-bart.properties 
else
	echo alfresco-bart.properties file not found, edit $0 and modify ALFBRT_PATH
fi

# Do not let this script run more than once
PROC=`ps axu | grep -v "grep" | grep --count "duplicity"`
if [ $PROC -gt 0 ]; then 
	echo "alfresco-bart.sh or duplicity is already running."
	exit 1
fi

# Command usage menu
usage(){
echo "USAGE:
    `basename $0` <mode> [set] [date <dest>]

Modes:
    backup [set]	runs an incremental backup or a full if first time
    restore [set] [date] [dest]	runs the restore, wizard if no arguments
    verify [set]	verifies the backup
    collection [set]	shows all the backup sets in the archive
    list [set]		lists the files currently backed up in the archive

Sets:
    all		do all backup sets
    index	use index backup set (group) for selected mode
    db		use data base backup set (group) for selected mode
    cs		use content store backup set (group) for selected mode
    files	use rest of files backup set (group) for selected mode"
}

# Checks if encryption is required if not it adds appropiate flag
if [ $ENCRYPTION_ENABLED = "true" ]; then
	export PASSPHRASE
else
	NOENCFLAG="--no-encryption"
fi

# Checks backup type, target selected
case $BACKUPTYPE in
	"s3" ) 
	    export AWS_ACCESS_KEY_ID="${AWS_ACCESS_KEY_ID}"
        export AWS_SECRET_ACCESS_KEY="${AWS_SECRET_ACCESS_KEY}"
		DEST=${S3FILESYSLOCATION}
		PARAMS="${GLOBAL_DUPLICITY_PARMS} ${S3OPTIONS} ${NOENCFLAG}"
		;;
	"ftp" ) 
		if [ ${FTPS_ENABLE} == 'false' ]; then
   			DEST=ftp://${FTP_USER}:${FTP_PASSWORD}@${FTP_SERVER}:${FTP_PORT}/${FTP_FOLDER}
   			PARAMS="${GLOBAL_DUPLICITY_PARMS} ${NOENCFLAG}"
		else
   			DEST=ftps://${FTP_USER}:${FTP_PASSWORD}@${FTP_SERVER}:${FTP_PORT}/${FTP_FOLDER}
   			PARAMS="${GLOBAL_DUPLICITY_PARMS} ${NOENCFLAG}"
		fi
		;;	
	"scp" )
		DEST=scp://${SCP_USER}@${SCP_SERVER}/${SCP_FOLDER}
		PARAMS="${GLOBAL_DUPLICITY_PARMS} ${NOENCFLAG}"
		;;
	"local" )
		# command sintax is "file:///" but last / is coming from ${LOCAL_BACKUP_FOLDER} variable
		DEST=file://${LOCAL_BACKUP_FOLDER}
{'fraction_non_alphanumeric': 0.20520148613889683, 'fraction_numerical': 0.005001428979708488, 'mean_word_length': 4.653473344103393, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3786706', 'n_tokens_mistral': 2378, 'n_tokens_neox': 2252, 'n_words': 686}