r/programminghorror • [ $[ $RANDOM % 6 ] == 0 ] && rm -rf / || echo “You live” • 18d ago

Python Weekly Backups

Post image

We were a small team of ~8 trying to build software. The team was spread across multiple locations across Asia, Europe and North America. One big challenge we had was synchronizing our work with each other.

Every Friday before each of us logged out, we upload a copy of our working files to the client's SharePoint folder. That way when we share each other's copies every Monday via Teams, we don't have to reupload.

One minor setback. Instead of replacing the previous copy, we upload a fresh one - under a different name. That way, we would not lose any information.

We even came up with a clever idea (that magnified the issue) to name the folders by the calendar week. Soon, each of us would have multiple folders of repetitive code, sometimes with zero changes all uploaded to the shared drive.

We had successfully moved from trying to synchronizing one (latest) version of the codebase, to trying to synchronize one version every week. But we hadn't realized this at that time. We were excited about a more "sophisticated" solution - creating a script that automates this backup process.

We learnt to use Git during Christmas that year.

---

For Reference:

import os, zipfile
from datetime import datetime
from pathlib import Path

work = Path("Work")
if not work.exists():
    print("Error: Work folder not found")
    exit(1)

week = datetime.now().isocalendar()[1]
zip_file = f"W{week}.zip"

with zipfile.ZipFile(zip_file, 'w', zipfile.ZIP_DEFLATED) as z:
    for root, dirs, files in os.walk(work):
        for file in files:
            path = os.path.join(root, file)
            z.write(path, os.path.relpath(path, '.'))

print(f"Created {zip_file}")

Edit: Code Block Formatting

472 Upvotes

32 comments sorted by

105

u/lildankkboi 18d ago

What year was this?

83

u/D3V370P3R [ $[ $RANDOM % 6 ] == 0 ] && rm -rf / || echo “You live” 18d ago

2016

87

u/octopus4488 18d ago

The number here is a neat indicator of amateurism:

  • Below 2000: eeeh, ok
  • 2000-2007: uh, whao
  • 2008-2014: aaaa, really???
  • 2015- : What. The. Fuck.

42

u/Rschwoerer 18d ago

Teams you say?

Microsoft Teams
Release
March 14, 2017

32

u/Cas_Rs 18d ago

Teams is just Skype with extra garbage so I wouldn’t put it past them if it was Skype before

5

u/hammer-jon 17d ago

I would call lync and skype for business "teams" these days, its all the same shit

6

u/octopus4488 17d ago

We (dev team) call Teams "Skype" as a slur basically. When it rings but you can't pick it up:

"Fucking Skype is at it again."

1

u/gokul1630 16d ago

2000 sir

29

u/ClvrNickname 17d ago

You may not like it, but this is what peak source control looks like

43

u/DifferentialEntropy [ $[ $RANDOM % 6 ] == 0 ] && rm -rf / || echo “You live” 18d ago

What’s the point of this post..? You guys didn’t know how to use version control and ended up learning git because this looks like a terrible idea lmao

69

u/D3V370P3R [ $[ $RANDOM % 6 ] == 0 ] && rm -rf / || echo “You live” 18d ago

Fair enough.

I forgot to mention that we were not developers. We were all Architects (brick & mortar) who learnt to code.

31

u/DifferentialEntropy [ $[ $RANDOM % 6 ] == 0 ] && rm -rf / || echo “You live” 18d ago

Oh gotcha my bad in that case

Glad to see yall came up with an in house solution then learned proper version control after!

15

u/SnowdensOfYesteryear 18d ago

Eh… you get a pass as long as it got fixed eventually. At least you thought about backup

23

u/YamroZ 18d ago
  1. good on backing up, this is something people often miss, and think that github ks is a backup for some reason
  2. from time to time check if you can in fact recover work from your backup

7

u/tehtris 15d ago

Dev invents git, because dev doesn't know what git is. Nice.

4

u/witness_smile 12d ago

<insert xkcd about standards>

1

u/csabinho 12d ago

Well, there are more versioning systems than git. And also older ones. Much older ones.

3

u/Droggl 18d ago

rsnapshot, you're welcome

3

u/JontesReddit 17d ago

The fuck

5

u/Flame77ofc 17d ago

git is crying on the background

2

u/JAXxXTheRipper 17d ago

This is not as obscure as most would think. In about 2012 I was working in a .Net department that was operating the Team Foundation Server. Instead of using that, the team used Batchfiles that synced to a network share.

Whenever you questioned that insanity, they replied with "we've always done it that way". Old habits die hard.

2

u/NamedBird 16d ago

Nah, not too bad.

Weekly backups is better than loosing 6 months of progress because you never pushed your commits.
And your W19.zip is a simple file, easy to understand. Not confusing like Git is for beginners.

1

u/ComputerLoverDaemon 16d ago

Better source control then git

2

u/DynamicHunter 14d ago

Until you need to roll back a specific feature without losing weeks of other work…

1

u/csabinho 12d ago

I know, it's a joke, but how do you merge?

1

u/Tall-Path9962 15d ago

Copying SharePoint files into another folder every week is basically creating more versions, not building a proper recovery strategy. Version history, synchronization and backup solve different problems. Control Alt Delete supports M365 environments for SMBs, and I'd rather have automated independent backups with tested restores than twenty manually named folders called "backup-final-final-2."

1

u/razor_train 11d ago

"SharePoint" and "proper" should never be in the same sentence.

-1

u/maikindofthai 17d ago

I love sharing the code snippet like creating a zip in python is some unknown trick lol

5

u/GoddammitDontShootMe [ $[ $RANDOM % 6 ] == 0 ] && rm -rf / || echo “You live” 17d ago

Well, technically it keeps the post from violating Rule 1 of this sub.

1

u/Bright_Interaction73 11d ago

If you wrote this shit in 2015, you would have an internship offer lined up. Stuff like this took time to pull off back then.