Close Menu
    DevStackTipsDevStackTips
    • Home
    • News & Updates
      1. Tech & Work
      2. View All

      CodeSOD: Back Up for a Moment

      July 14, 2025

      This week in AI dev tools: Gemini API Batch Mode, Amazon SageMaker AI updates, and more (July 11, 2025)

      July 11, 2025

      JFrog finds MCP-related vulnerability, highlighting need for stronger focus on security in MCP ecosystem

      July 11, 2025

      8 Key Questions Every CEO Should Ask Before Hiring a Node.js Development Company in 2025

      July 11, 2025

      DistroWatch Weekly, Issue 1130

      July 13, 2025

      Distribution Release: GParted Live 1.7.0-8

      July 13, 2025

      Distribution Release: CachyOS 250713

      July 13, 2025

      Most AI projects are abandoned – 5 ways to ensure your data efforts succeed

      July 13, 2025
    • Development
      1. Algorithms & Data Structures
      2. Artificial Intelligence
      3. Back-End Development
      4. Databases
      5. Front-End Development
      6. Libraries & Frameworks
      7. Machine Learning
      8. Security
      9. Software Engineering
      10. Tools & IDEs
      11. Web Design
      12. Web Development
      13. Web Security
      14. Programming Languages
        • PHP
        • JavaScript
      Featured

      Set up an AI-powered Laravel Development Environment with Claude Code and MCP Servers

      July 14, 2025
      Recent

      Set up an AI-powered Laravel Development Environment with Claude Code and MCP Servers

      July 14, 2025

      The details of TC39’s last meeting

      July 14, 2025

      new Date(“wtf”) – How well do you know JavaScript’s Date class?

      July 12, 2025
    • Operating Systems
      1. Windows
      2. Linux
      3. macOS
      Featured

      Texel is a free chess engine

      July 14, 2025
      Recent

      Texel is a free chess engine

      July 14, 2025

      HDF Compass – experimental viewer program for HDF5

      July 14, 2025

      DistroWatch Weekly, Issue 1130

      July 13, 2025
    • Learning Resources
      • Books
      • Cheatsheets
      • Tutorials & Guides
    Home»Tech & Work»CodeSOD: Back Up for a Moment

    CodeSOD: Back Up for a Moment

    July 14, 2025

    James‘s team has a pretty complicated deployment process implemented as a series of bash scripts. The deployment is complicated, the scripts doing the deployment are complicated, and failures mid-deployment are common. That means they need to gracefully roll back, and they way they do that is by making backup copies of the modified files.

    This is how they do that.

    DATE=`date '+%Y%m%d'`
    BACKUPDIR=`dirname ${DESTINATION}`/backup
    if [ ! -d $BACKUPDIR ]
    then
            echo "Creating backup directory ..."
            mkdir -p $BACKUPDIR
    fi
    FILENAME=`basename ${DESTINATION}`
    BACKUPFILETYPE=${BACKUPDIR}/${FILENAME}.${DATE}
    BACKUPFILE=${BACKUPFILETYPE}-1
    if [ -f ${BACKUPFILE} ] || [ -f ${BACKUPFILE}.gz ] ; then BACKUPFILE=${BACKUPFILETYPE}-2 ; fi
    if [ -f ${BACKUPFILE} ] || [ -f ${BACKUPFILE}.gz ] ; then BACKUPFILE=${BACKUPFILETYPE}-3 ; fi
    if [ -f ${BACKUPFILE} ] || [ -f ${BACKUPFILE}.gz ] ; then BACKUPFILE=${BACKUPFILETYPE}-4 ; fi
    if [ -f ${BACKUPFILE} ] || [ -f ${BACKUPFILE}.gz ] ; then BACKUPFILE=${BACKUPFILETYPE}-5 ; fi
    if [ -f ${BACKUPFILE} ] || [ -f ${BACKUPFILE}.gz ] ; then BACKUPFILE=${BACKUPFILETYPE}-6 ; fi
    if [ -f ${BACKUPFILE} ] || [ -f ${BACKUPFILE}.gz ] ; then BACKUPFILE=${BACKUPFILETYPE}-7 ; fi
    if [ -f ${BACKUPFILE} ] || [ -f ${BACKUPFILE}.gz ] ; then BACKUPFILE=${BACKUPFILETYPE}-8 ; fi
    if [ -f ${BACKUPFILE} ] || [ -f ${BACKUPFILE}.gz ] ; then BACKUPFILE=${BACKUPFILETYPE}-9 ; fi
    if [ -f ${BACKUPFILE} ] || [ -f ${BACKUPFILE}.gz ] ; then
    cat <<EOF
    You have already had 9 rates releases in one day.
    
    ${BACKUPFILE} already exists, do it manually !!!
    EOF
    exit 2
    fi
    

    Look, I know that loops in bash can be annoying, but they’re not that annoying.

    This code creates a backup directory (if it doesn’t already exist), and then creates a file name for the file we’re about to backup, in the form OriginalName.Ymd-n.gz. It tests to see if this file exists, and if it does, it increments n by one. It does this until either it finds a file name that doesn’t exist, or it hits 9, at which point it gives you a delightfully passive aggressive message:

    You have already had 9 rates releases in one day.
    ${BACKUPFILE} already exists, do it manually !!!

    Yeah, do it manually. Now, admittedly, I don’t think a lot of folks want to do more than 9 releases in a given day, but there’s no reason why they couldn’t just keep trying until they find a good filename. Or even better, require each release to have an identifier (like the commit or build number or whatever) and then use that for the filenames.

    Of course, just fixing this copy doesn’t address the real WTF, because we laid out the real WTF in the first paragraph: deployment is a series of complicated bash scripts doing complicated steps that can fail all the time. I’ve worked in places like that, and it’s always a nightmare. There are better tools! Our very own Alex has his product, of course, but there are a million ways to get your builds repeatable and reliable that don’t involve BuildMaster but also don’t involve fragile scripts. Please, please use one of those.

    [Advertisement] Plan Your .NET 9 Migration with Confidence
    Your journey to .NET 9 is more than just one decision.Avoid migration migraines with the advice in this free guide. Download Free Guide Now!

    Source: Read More 

    news
    Facebook Twitter Reddit Email Copy Link
    Previous ArticleCritical Cisco Vulnerability in Unified CM Grants Root Access via Static Credentials
    Next Article Set up an AI-powered Laravel Development Environment with Claude Code and MCP Servers

    Related Posts

    Tech & Work

    This week in AI dev tools: Gemini API Batch Mode, Amazon SageMaker AI updates, and more (July 11, 2025)

    July 11, 2025
    Tech & Work

    JFrog finds MCP-related vulnerability, highlighting need for stronger focus on security in MCP ecosystem

    July 11, 2025
    Leave A Reply Cancel Reply

    For security, use of Google's reCAPTCHA service is required which is subject to the Google Privacy Policy and Terms of Use.

    Continue Reading

    MIT and Mass General Brigham launch joint seed program to accelerate innovations in health

    Artificial Intelligence

    CVE-2025-4240 – PCMan FTP Server LCD Command Handler Buffer Overflow Vulnerability

    Common Vulnerabilities and Exposures (CVEs)

    High-Entropy Token Selection in Reinforcement Learning with Verifiable Rewards (RLVR) Improves Accuracy and Reduces Training Cost for LLMs

    Machine Learning

    CVE-2025-4646 – Centreon Web Privilege Escalation Vulnerability

    Common Vulnerabilities and Exposures (CVEs)

    Highlights

    CVE-2025-47711 – “nbdkit Denial-of-Service Vulnerability”

    June 9, 2025

    CVE ID : CVE-2025-47711

    Published : June 9, 2025, 6:15 a.m. | 3 hours, 23 minutes ago

    Description : There’s a flaw in the nbdkit server when handling responses from its plugins regarding the status of data blocks. If a client makes a specific request for a very large data range, and a plugin responds with an even larger single block, the nbdkit server can encounter a critical internal error, leading to a denial-of-service.

    Severity: 4.3 | MEDIUM

    Visit the link for more details, such as CVSS details, affected products, timeline, and more…

    CVE-2025-43922 – FileWave Windows Privilege Escalation

    April 21, 2025

    CVE-2025-39471 – Pantherius Modal Survey SQL Injection Vulnerability

    April 22, 2025

    The sweet taste of a new idea

    May 19, 2025
    © DevStackTips 2025. All rights reserved.
    • Contact
    • Privacy Policy

    Type above and press Enter to search. Press Esc to cancel.