0

so for a course I'm currently studying I have a test to do soon. (It's a low level course) We are using RHEL6 and we've been given a sample test to work through. There's one single question I can't seem to work out, as I don't recall the teacher ever explaining anything like it. The exact question is this:

Perform an automatic backup of the /home directory using the tar command, at 02:00 a.m. every Saturday morning. Save this backup under a directory called /backup with the file name system_backup.tar.bz. Note that all backups are to be performed according to the organization standards which require us to view the time stamp on system_backup.tar.bz to ensure it is the latest file that was created.

I know how to make the directory for the backup, and I know how to archive things using tar, but I'm really not sure how to go about automating this process, as I haven't been taught how! I'm a little concerned, and everything I've found online has been fairly confusing. If anyone can help I'd greatly appreciate it! Thanks in advance.

0

yes, you will need to set a cron job that runs at xyz military time. The crontab sole job is to kick start a script that you will have to write "like the one below". The script can be written in shell and added to cron to be excuted at xyz time.

Read about cron here . https://wiki.archlinux.org/index.php/cron.

Read this answer: https://askubuntu.com/questions/350861/how-to-set-a-cron-job-to-run-a-shell-script

Here is a sample script I found online.

#!/bin/sh

BKUP_FILE_NAME="bkup-"`date +%Y-%m-%d`".tgz.enc"

# trap ctrl-c and call ctrl_c()
trap ctrl_c INT

function ctrl_c() {
        echo "Exiting..."
        exit 1
}

if [[ $1 == '-d' ]];
then
        # Decrypt
        openssl aes-256-cbc -d -salt -in $2 | tar xzf -
        exit 0
fi

mkdir bkup

rsync -r --relative .dwm/config.h bkup/
rsync -r --relative .st/config.h bkup/
rsync -r --relative .ssh bkup/


# Thunderbird
rsync -r --relative .thunderbird/ bkup/
rm -r bkup/.thunderbird/*.default/*.sqlite

# Pidgin
rsync -r --relative .purple bkup/
rm -r bkup/.purple/logs

# Encrypt
tar cz bkup | openssl aes-256-cbc -salt -out $BKUP_FILE_NAME

# Clean up
rm -r bkup

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.