CanDo Maintenance and Backups
System Maintenance
Maintenance of Ubuntu Linux and CanDo is generally as simple as regularly running
sudo apt-get update sudo apt-get upgrade
When the kernel packages are updated, you will want to reboot your server.
sudo shutdown -r now
More information can be found in the Ubuntu server documentation.
Packing the database
To maintain good system performance, the CanDo database should be "packed" from time to time. The Schooltool Web site provides instructions.
Backups - the least you need to know
The CanDo database file is kept at /var/lib/schooltool/schooltool-cando-Data.fs. This is the one file you absolutely must back up regularly. In order to back it up you must give your user account permission to read this directory and file by adding your account to the schooltool group. (For <username> subsitute your user name.)
sudo usermod -a -G schooltool <username>
Log out and log back in to confirm that you can now see this directory
sudo ls -l /var/lib/schooltool
Now you should be able to back up that file using common SFTP-capable tools, such as FileZilla or Cyberduck (Mac only).
Other backup strategies, such as backing up to network shares and compression are of course possible. The Ubuntu server documentation includes some discussion. Please feel free to ask Lee Capps for help, if you have specific questions.
Additional information about SchoolTool/CanDo backups is available at the SchoolTool Website.
NOTE: We cannot recommend making backups using File Transfer Protocol (FTP) as under certain circumstances file corruption can occur. Whatever backup scheme you choose, it is imperative that you test restoring from your backups before you need to rely on them on your production server.
Snapshots
It can be useful to keep "snapshots" of the state of CanDo at particular moments in time. Here is one way to accomplish this. NOTE: This script does not rotate the snapshots. If you use this method, you will need to clean up the file system manually to keep it from filling. How often you have to do so, depends on server space.
First, add your user account to the schooltool group as detailed above.
Create directories to store the snapshots.
sudo mkdir -p /var/lib/schooltool/cando-backups/zip chown -R schooltool:schooltool /var/lib/schooltool/cando-backups
Now copy this script to /etc/cron.daily.
wget http://cando.cteresource.org/cando-daily-pkg.py chmod +x cando-daily-pkg.py sudo mv cando-daily-pkg.py /etc/cron.daily/cando-snapshot
The script will now be run daily by the run-parts utility. Time-stamped copies of the database file will be kept in /var/lib/schooltool/cando-backups. Compressed copies are kept in /var/lib/schooltool/cando-backups/zip. While the script is running, CanDo will be unavailable to users, so you will want to check the time that run-parts is set to run and modify as necessary.
sudo nano /etc/crontab
Look for the line that includes 'cron.daily.' In this example, the scripts in /etc/cron.daily are run beginning at 6:25 a.m.
25 6 * * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )
The daily scripts could be made to run starting at 3:25 a.m. simply by changing the 6 in the second column to a 3.
25 3 * * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )
Restore
Whatever backup strategy you choose, it is wise to test that you can restore from backups before relying on it and to test again periodically.
To restore from a backup, stop the server, backup the live database (just in case), copy the backup into place, and restart the server:
sudo /etc/init.d/schooltool-cando stop sudo cp /var/lib/schooltool/schooltool-cando-Data.fs ~/Data.fs.just.in.case sudo cp /path/to/backup/Data.fs /var/lib/schooltool/schooltool-cando-Data.fs sudo chown schooltool:schooltool /var/lib/schooltool/schooltool-cando-Data.fs sudo chmod 644 /var/lib/schooltool/schooltool-cando-Data.fs sudo /etc/init.d/schooltool-cando start
The server will take some time to come back online as it processes the restored database file. You can monitor this process, using the top command. When CPU uitilization drops back down to normal levels, you should be able to log into your restored CanDo instance.
