Cron backup inside external user folder

Aaron1232

New member
Joined
Aug 28, 2022
Messages
1
Location
Belgium
Hello,

Can someone help me with a special backup solution?

I want to create a user folder on a external FTP server with the username when the user has been created.
Then i want every night to create a backup inside the user folder with the date of the month (something like: aaron/1/ aaron/2/ ).

And when the user has been deleted, de backup folder also been deleted from the backup location.

i can create a user folder inside the ftp with user_create_post.sh script, but i don't know how to backup to the external user folder.

Can someone advise / Help me with this?

Aaron
 
You should probably begin by writing a script to perform the backup for the current day. You can get the day using date:

Code:
DAYOFMONTH=$(date +%e)

Take the username as the first argument $1 . Unless you're on a private/local network, ideally you want to use SSH/SFTP rather than FTP, in which case you can create the backup using rsync or scp .

Then you need to call this script once a day for each user.

One way is to on the account creation script register a cron job to perform the backup for the user, using a method such as this. This can get messy, though. It's probably best to manually add a single nightly cron job that runs a master script that calls the backup script for every relevant user. You can use user_create_post to add users to the list of relevant users (that need to be backed up). You can just plop users in your own text file, or you can use an existing mechanism - for example, you could create a new linux group "backupusers" and add users to it when appropriate. Your cron job would get the list of users in this group and run the backup script for each of them.
 
Back
Top