Other backup script

I wish to create a script that compresses the folder ( /mnt/Live/jails/nextcloud_1/media) and the compressed file is saved to /mnt/Backups/NextCloud Backups
The file name should be according to the date of when the backup was executed.

Then on the 6th day the backup is deleted.

Any ideas if this can be done ?
 
Just use tar(1), it's really not that difficult to do. Create the script that does the backups, schedule it with crontab(1). Add a second script that does the cleanup.
 
currently I am trying to use the backup command manually and without the date name part but I am getting the below.:

tar -zcf mnt/Live/jails/nextcloud_1/media/test.tar.gz mnt/Backups/NextCloud_Backups

tar: Failed to clean up compressor


and when addin / in front of the path:

tar -zcf /mnt/Live/jails/nextcloud_1/media/test.tar.gz /mnt/Backups/NextCloud_Backups

tar: Removing leading '/' from member names
 
You're doing things the wrong way around. The -f option and its argument is the resulting archive name. Right now you're compressing everything in /mnt/Backups/NextCloud_Backups and saving it as /mnt/Live/jails/nextcloud_1/media/test.tar.gz. Which is the exact reverse of what you wanted to do.

Example: tar -zcvf /storage/mybackupfile.tgz /files/to/backup/
This backs up all files in /files/to/backup/ and saves it as /storage/mybackupfile.tgz.
 
the below script did the job:

Code:
#!/bin/sh
present=`date +'%d-%B-%Y'`

#backup nextcloud data folder and place it on the secondary raid

tar -zcvf /mnt/Backups/NextCloud_Backups/$present.tar.gz /mnt/Live/jails/nextcloud_1/media

#creates a logfile if the backup was successful

echo "bkup was done succesfully on $present" >> /mnt/Backups/NextCloud_Backups_Logs/DailyBackup_$present.log

Now I only need to test the removal of the old backups:

Code:
#deletes backup older than 7days
find /mnt/Backups/NextCloud_Backups/* -type d -ctime +7 | xargs rm -rf

echo "Backup was removed succesfully on $present" >> /mnt/Backups/NextCloud_Backups_Logs/DailyBackupCleanup_$present.log

#deletes log file older than 7 days
find /mnt/Backups/NextCloud_Backups_Logs/* -type d -ctime +7 | xargs rm -rf

echo "Backup_Log was removed succesfully on $present" >> /mnt/Backups/NextCloud_Backups_Logs/DailyLogCleanup_$present.log
 
Back
Top