Limiting number of remote backups
-
- Posts: 2
- Joined: Wed Sep 30, 2020 11:33 pm
Is it possible to configure a backup to a remote server via FTP once a week and leave a regular local backup every day, as configured by default in the control panel? How to do it?
- myVesta
- Site Admin
- Posts: 949
- Joined: Fri Jun 19, 2020 9:59 am
- Has thanked: 9 times
- Been thanked: 6 times
The only thing you can do is to limit number of remote backups that will be kept remotely.
or
That way only last backup will be on remote backup.
Or
for last two backups.
Code: Select all
echo "ONLY_ONE_FTP_BACKUP='yes'" >> /usr/local/vesta/conf/vesta.conf
Code: Select all
echo "KEEP_N_FTP_BACKUPS=1" >> /usr/local/vesta/conf/vesta.conf
Or
Code: Select all
echo "KEEP_N_FTP_BACKUPS=2" >> /usr/local/vesta/conf/vesta.conf
-
- Posts: 2
- Joined: Wed Sep 30, 2020 11:33 pm
Dear dpeca,
Thank you for your answer, but the limiting number of remote backups is not what I need.
We need an individual schedule for remote backups so that daily backups for the last 7 days are stored locally, and weekly backups for the last couple of months are stored on the remote FTP server.
Thank you for your answer, but the limiting number of remote backups is not what I need.
We need an individual schedule for remote backups so that daily backups for the last 7 days are stored locally, and weekly backups for the last couple of months are stored on the remote FTP server.
I have create a script to do almost exactly this using rclone to my Google Drive (rather than FTP) - I'm not very proficient with bash, but I managed to kludge together the script and it works perfectly if I run it in a terminal window. The problem I'm having is how to get that script to actually run as a cron job.welldesign wrote: ↑Fri Oct 02, 2020 10:34 am We need an individual schedule for remote backups so that daily backups for the last 7 days are stored locally, and weekly backups for the last couple of months are stored on the remote FTP server.
I have a cron job set to run a couple hours after the backups are done:
sudo /usr/bin/bash /backup/remote-backup.sh > /backup/remote-backup.log 2>&1
It fires, but I'm getting this message in the log:
sudo: no tty present and no askpass program specified
I did some searches about this error and found suggestions that the entry in sudoers was either missing or incorrect. From what I can see the "admin" user, under which the cron jobs run, is only allowed to run the Vesta scripts using sudo?
# sudo is limited to vesta scripts
admin ALL=NOPASSWD:/usr/local/vesta/bin/*
I assume I could adjust the /etc/sudoers.d/admin file, but:
a) I believe that's dangerous to do manually and my knowledge of visudo is limited, so I don't know if it can be used to edit that admin file, and
b) I suspect any changes would be overwritten by future updates?
So I'm a little stuck on how to actually automate the process. Happy to share the process and script.
So I did some more digging today and (hopefully) I have come up with a solution to my issue. First I found that for most of my script root privileges aren't required, so I just removed the "sudo" from the start of the cron job and the script mostly worked.
However, for one section, which is more specific to my system, my script DOES need to call rclone with root privileges because it needs to delete some local files that are in a directory which only root can delete from. In order to enable that, I used visudo to add a line to the /etc/sudoers file:
admin ALL=(ALL) NOPASSWD:/bin/rclone
The cron then seems to fire and work perfectly. But I do have a question that you might be able to help me with. Now that I've added that entry, will it have any negative impact on these lines in the /etc/sudoers.d/admin file:
# sudo is limited to vesta scripts
admin ALL=NOPASSWD:/usr/local/vesta/bin/*
I'm assuming not, but obviously, if it does, the other system cron tasks won't run properly! Also, are there any other negative implications of adding that line to the /etc/sudoers file?
Thanks again for a fantastic fork!
However, for one section, which is more specific to my system, my script DOES need to call rclone with root privileges because it needs to delete some local files that are in a directory which only root can delete from. In order to enable that, I used visudo to add a line to the /etc/sudoers file:
admin ALL=(ALL) NOPASSWD:/bin/rclone
The cron then seems to fire and work perfectly. But I do have a question that you might be able to help me with. Now that I've added that entry, will it have any negative impact on these lines in the /etc/sudoers.d/admin file:
# sudo is limited to vesta scripts
admin ALL=NOPASSWD:/usr/local/vesta/bin/*
I'm assuming not, but obviously, if it does, the other system cron tasks won't run properly! Also, are there any other negative implications of adding that line to the /etc/sudoers file?
Thanks again for a fantastic fork!
- myVesta
- Site Admin
- Posts: 949
- Joined: Fri Jun 19, 2020 9:59 am
- Has thanked: 9 times
- Been thanked: 6 times
in sudoers add:
and call script from cron with:
in /backup/remote-backup.sh as first line put:
and of course it needs +x chmod:
Code: Select all
admin ALL=NOPASSWD:/backup/*
Code: Select all
sudo /backup/remote-backup.sh > /backup/remote-backup.log 2>&1
Code: Select all
#!/bin/bash
Code: Select all
chmod a+x /backup/remote-backup.sh