Skip to main content

Time to archive

How to archive an entire YouTube channel


  1. Create a directory where you want your files to be
  2. Download or create the necessary files to create directories, move files and download videos. Examples:
    #!/bin/sh
    
    if [ ! -d "audio" ] ; then
    mkdir audio && mkdir metadata && mkdir thumbnails && mkdir descriptions && echo "Created directories"
    fi
    #!/bin/bash
    
    if compgen -G "*.mp3" > /dev/null ; then
    mv *.mp3 audio/ && mv *.webp thumbnails/ && mv *.description descriptions/ && mv *.info.json metadata/ && echo "Moved files"
    fi
    #!/bin/bash
    yt-dlp --config-location /srv/dev-disk-by-uuid-fa1e36be-9ccc-4549-8734-fe6117b30317/croni/andre/andre/Archive/yt-dlp/yt-dlp_music.conf --download-archive youtube_backup_downloaded.txt --yes-playlist 'https://youtube.com/playlist?list=PLeEbifL6wH9okMEgTQP459RcTrjBWkF_b'
  3. Execute these files however you want. I personally would recommend to set up a cron job to periodically download new videos. Example:
    nohup ./backup.sh > backup.log &


  4. If you execute the command above your only way to know what yt-dlp is currently doing is to tail the log with tail -f backup.log

  5.  While waiting for the download to finish you can create the necessary directories to organize all your downloaded files. Example:
    #!/bin/sh
    
    if [ ! -d "audio" ] ; then
    mkdir audio && mkdir metadata && mkdir thumbnails && mkdir descriptions && echo "Created directories"
    fi

  6. When the download is finished an you created the directories it is time to move them to their dedicated directory. Example:
    #!/bin/bash
    
    if compgen -G "*.mp3" > /dev/null ; then
    mv *.mkv audio/ && mv *.webp thumbnails/ && mv *.description descriptions/ && mv *.info.json metadata/ && echo "Moved files"
    fi
  7. You successfully archived an entire YouTube channel 🚀


Tips

  • Make your files executable with sudo chmod +x file.sh
  • You can execute the files with ./file.sh
  • This guide can be adapted to download playlist and even single videos
    • If you only want to download one video then remove  --yes-playlist