Jim's
Tutorials

Fall 2019
course
site

Jim says (on Oct 20)

What you have here generally looks fine.

One comment is that I thing your PuTTY/pscp tech stack may be somewhat dated. While I'm not sure what version of Windows you're using, I think that today's Windows PowerShell includes ssh & scp. See this for example. And on newer version it may just work. My impression is that PowerShell is much more like the unix bash in its abilities.

Another shell to consider is the windows subsystem for linux which would let you do the same stuff that you're doing on ubuntu in a microsoft supported tool.

As for making archives of the stuff you've submitted on cs.marlboro.college, we can certainly find a way to do that. Everything you've turned in is in a folder on an ubuntu system - I can put together a script that will do that. In the past I gave students shell accounts on this machine, but I haven't really set it up to give access with the privileges that would "do the right thing".

I hope you're feeling better, and will see you next week.

Another aside : don't call yourself a programmer and other career advie | discussion . Definitely read the discussion - the essay is one point of view but not entirely confirmed by the comments.

Alex - Oct 17

The UNIX game is actually really cool. I always find learning with tools like that to be useful practice. In general I think teaching tools in the form of games are a bit of an underutilized market outside of early education which is a shame.

I wanted to get more done this week but having been bedridden from the weekend through til now I figured I'd stick to what we had gone over, namely, getting the backups going with tar/cron instead of worrying about Django right yet. I also wanted to mess around with pip a bit, as it sounds very useful from our conversation.

If I'm still this sick tomorrow I'll likely talk with you after Python as I'd rather not make you sick. Hopefully I'll be feeling better, though. Has been exhausting.

Documentation of tar/crontab

Created a backup directory at:

Checked the size of what I was trying to backup (in this case, my html folders). Also used df -h to check available disk space on the system.

du -s -h /var/www/html showed that the backup would be 8M worth of files.

Tested tar command sudo tar -cvpzf /var/www_backup/webrootbackup.co.tar.gz -C /var/www/ html

This would:

sudo tar = execute  tar as superuser
c = create new file (overwrites old file)
v = verbose (will show backup progress on screen)
p = preserve permissions (755, 777, etc)
z = compress (compress the archive into a “tarball”)
f = filename
/var/www_backup/webrootbackup.com.tar.gz = the path and name of the backup archive that will be created.
-C = (uppercase C) = change to this directory
/var/www/ = the path to the folder above your document root
= SPACE (Important!)
html = the name of the actual document root folder

Checked to make sure this worked properly using: ls -l --block-size=M /var/www_backup/

This showed me that it was indeed 8M and the correct .tar.gz had been generated with the output of:

-rw-r--r-- 1 root root 8M Oct 16 20:30 webrootbackup.co.tar.gz

Configuring cron using crontab:

sudo crontab -e

00 01 * * * sudo tar -cvpzf /var/www_backup/webrootbackup.co.tar.gz -C /var/www/ html

This will run the backup everyday at 1AM and replace the previous backup archive.

Once it runs I can use sudo grep CRON /var/log/syslog to find it in the log.

Found this documentation on https://devanswers.co/how-to-automatically-backup-web-server-doc-root-tar-cron/ :

.------------ minute (0-59) (* = every minute)
| .---------- hour (0-23) (* = every hour)
| | .-------- day of month (1-31) (* = every day)
| | | .------ month (1-12 or jan-dec) (* = every month)
| | | | .---- day of week (0-6 or mon-sun) (Sunday=0) (* = every day)
| | | | |
* * * * * command_to_run

As well as:

30 23 * * *       Every day at 11.30pm
0 0 * * *         Every day at midnight (00:00)
*/10 * * * *      Every 10 mins
0 */12 * * *      Every 12 hours 
0 17 * * sun      Every Sunday at 5pm
0 17 * * sun,mon  Every Sunday and Monday at 5pm
0 5,17 * * *      At 5am and 5pm daily
0 12 1 jan,feb *  At 12pm on the 1st of every Jan and Feb
0 0 1 * *         The 1st day of every month at midnight

PuTTY won't allow for SCP so I used a program from them called pscp to download the backup to my computer. It's a shame, because I wanted to make an alias for this command but I don't know that I can through their pscp program. It would be perfect for an alias if I can get that to work.

With pscp I use this command in my cmd prompt:

pscp noms@45.79.134.85:/var/www_backup/webrootbackup.co.tar.gz C:\Users\alexr\Desktop\Marlboro

For now, simply having this command typed down for copy/paste works. If I could make it an alias like "getdailybackup" that would be pretty cool.

Unrelated, is there a way to curl my Python assignment page at the end of semester? Your format for submitting assignments is very nice as I'll be able to backup my work easier than I did for Javascript, however, if I could use curl to pull all that into files it may be a fun use for that. I like backing up my coding work, as leap year came in handy from my Javascript for Python for this weeks assignment. If curl doesn't work, I can simply copy paste each page into a document fast enough. Just thought it would be a nifty use for it.

aside

the unix game | discussion

https://cs.marlboro.college /cours /fall2019 /jims_tutorials /arome /oct17
last modified Thu November 21 2024 5:10 pm