{"id":16621321,"url":"https://github.com/androz2091/discord-backup","last_synced_at":"2025-05-16T04:04:08.865Z","repository":{"id":36935866,"uuid":"189615808","full_name":"Androz2091/discord-backup","owner":"Androz2091","description":"📦 Complete framework to facilitate server backup using discord.js v13","archived":false,"fork":false,"pushed_at":"2024-03-31T09:44:34.000Z","size":273,"stargazers_count":449,"open_issues_count":64,"forks_count":86,"subscribers_count":10,"default_branch":"master","last_synced_at":"2025-05-11T19:41:32.693Z","etag":null,"topics":["backup","clone","discord","framework","server"],"latest_commit_sha":null,"homepage":"https://npmjs.com/package/discord-backup","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Androz2091.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"patreon":"androz2091","github":"Androz2091"}},"created_at":"2019-05-31T15:18:12.000Z","updated_at":"2025-05-03T21:02:36.000Z","dependencies_parsed_at":"2024-06-18T13:36:13.655Z","dependency_job_id":"0582a7d2-3037-405c-9f7a-a33b004ae80c","html_url":"https://github.com/Androz2091/discord-backup","commit_stats":{"total_commits":226,"total_committers":12,"mean_commits":"18.833333333333332","dds":"0.22123893805309736","last_synced_commit":"79e9adc72f0ea8d379989439284b58f8c25c8d1b"},"previous_names":[],"tags_count":29,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Androz2091%2Fdiscord-backup","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Androz2091%2Fdiscord-backup/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Androz2091%2Fdiscord-backup/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Androz2091%2Fdiscord-backup/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Androz2091","download_url":"https://codeload.github.com/Androz2091/discord-backup/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254464891,"owners_count":22075570,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["backup","clone","discord","framework","server"],"created_at":"2024-10-12T02:46:59.613Z","updated_at":"2025-05-16T04:04:08.847Z","avatar_url":"https://github.com/Androz2091.png","language":"TypeScript","funding_links":["https://patreon.com/androz2091","https://github.com/sponsors/Androz2091"],"categories":[],"sub_categories":[],"readme":"# Discord Backup\n\n[![downloadsBadge](https://img.shields.io/npm/dt/discord-backup?style=for-the-badge)](https://npmjs.com/discord-backup)\n[![versionBadge](https://img.shields.io/npm/v/discord-backup?style=for-the-badge)](https://npmjs.com/discord-backup)\n\n**Note**: this module uses recent discordjs features and requires discord.js v13.\n\nDiscord Backup is a powerful [Node.js](https://nodejs.org) module that allows you to easily manage discord server backups.\n\n* Unlimited backups!\n* Backup creation takes less than 10 seconds!\n* Even restores messages with webhooks!\n* And restores everything that is possible to restore (channels, roles, permissions, bans, emojis, name, icon, and more!)\n\n## Changelog\n\n* Supports base64 for emojis/icon/banner backup\n* New option to save backups in your own database\n* `backup#delete()` removed in favor of `backup#remove()`\n\n## Installation\n\n```js\nnpm install --save discord-backup\n```\n\n## Examples\n\nYou can read this example bot on Github: [backups-bot](https://github.com/Androz2091/backups-bot)\n\n### Create\n\nCreate a backup for the server specified in the parameters!\n\n```js\n/**\n * @param {Guild} [Guild] - The discord server you want to backup\n * @param {object} [options] - The backup options\n */\n\nconst backup = require(\"discord-backup\");\nbackup.create(Guild, options).then((backupData) =\u003e {\n    console.log(backupData.id); // NSJH2\n});\n```\n\nClick [here](#create-advanced) to learn more about **backup options**.\n\n### Load\n\nAllows you to load a backup on a Discord server!\n\n```js\n/**\n * @param {string} [backupID] - The ID of the backup that you want to load\n * @param {Guild} [Guild] - The discord server on which you want to load the backup\n */\n\nconst backup = require(\"discord-backup\");\nbackup.load(backupID, Guild).then(() =\u003e {\n    backup.remove(backupID); // When the backup is loaded, it's recommended to delete it\n});\n```\n\n### Fetch\n\nFetches information from a backup\n\n```js\n/**\n * @param {string} [backupID] - The ID of the backup to fetch\n */\n\nconst backup = require(\"discord-backup\");\nbackup.fetch(backupID).then((backupInfos) =\u003e {\n    console.log(backupInfos);\n    /*\n    {\n        id: \"BC5qo\",\n        size: 0.05\n        data: {BackupData}\n    }\n    */\n});\n```\n\n### Remove\n\n**Warn**: once the backup is removed, it is impossible to recover it!\n\n```js\n/**\n * @param {string} [backupID] - The ID of the backup to remove\n */\n\nconst backup = require(\"discord-backup\");\nbackup.remove(backupID);\n```\n\n### List\n\n**Note**: `backup#list()` simply returns an array of IDs, you must fetch the ID to get complete information.\n\n```js\nconst backup = require(\"discord-backup\");\nbackup.list().then((backups) =\u003e {\n    console.log(backups); // Expected Output [ \"BC5qo\", \"Jdo91\", ...]\n});\n```\n\n### SetStorageFolder\n\nUpdates the storage folder to another\n\n```js\nconst backup = require(\"discord-backup\");\nbackup.setStorageFolder(__dirname+\"/backups/\");\nawait backup.create(guild); // Backup created in ./backups/\nbackup.setStorageFolder(__dirname+\"/my-backups/\");\nawait backup.create(guild); // Backup created in ./my-backups/\n```\n\n## Advanced usage\n\n### Create [advanced]\n\nYou can use more options for backup creation:\n\n```js\nconst backup = require(\"discord-backup\");\nbackup.create(guild, {\n    maxMessagesPerChannel: 10,\n    jsonSave: false,\n    jsonBeautify: true,\n    doNotBackup: [ \"roles\",  \"channels\", \"emojis\", \"bans\" ],\n    saveImages: \"base64\"\n});\n```\n\n**maxMessagesPerChannel**: Maximum of messages to save in each channel. \"0\" won't save any messages.  \n**jsonSave**: Whether to save the backup into a json file. You will have to save the backup data in your own db to load it later.  \n**jsonBeautify**: Whether you want your json backup pretty formatted.  \n**doNotBackup**: Things you don't want to backup. Available items are: `roles`, `channels`, `emojis`, `bans`.  \n**saveImages**: How to save images like guild icon and emojis. Set to \"url\" by default, restoration may not work if the old server is deleted. So, `url` is recommended if you want to clone a server (or if you need very light backups), and `base64` if you want to backup a server. Save images as base64 creates heavier backups.\n\n### Load [advanced]\n\nAs you can see, you're able to load a backup from your own data instead of from an ID:\n\n```js\nconst backup = require(\"discord-backup\");\nbackup.load(backupData, guild, {\n    clearGuildBeforeRestore: true\n});\n```\n\n**clearGuildBeforeRestore**: Whether to clear the guild (roles, channels, etc... will be deleted) before the backup restoration (recommended).  \n**maxMessagesPerChannel**: Maximum of messages to restore in each channel. \"0\" won't restore any messages.\n\n## Example Bot\n\n```js\n// Load modules\nconst Discord = require(\"discord.js\"),\nbackup = require(\"discord-backup\"),\nclient = new Discord.Client(),\nsettings = {\n    prefix: \"b!\",\n    token: \"YOURTOKEN\"\n};\n\nclient.on(\"ready\", () =\u003e {\n    console.log(\"I'm ready !\");\n});\n\nclient.on(\"message\", async message =\u003e {\n\n    // This reads the first part of your message behind your prefix to see which command you want to use.\n    let command = message.content.toLowerCase().slice(settings.prefix.length).split(\" \")[0];\n\n    // These are the arguments behind the commands.\n    let args = message.content.split(\" \").slice(1);\n\n    // If the message does not start with your prefix return.\n    // If the user that types a message is a bot account return.\n    // If the command comes from DM return.\n    if (!message.content.startsWith(settings.prefix) || message.author.bot || !message.guild) return;\n\n    if(command === \"create\"){\n        // Check member permissions\n        if(!message.member.hasPermission(\"ADMINISTRATOR\")){\n            return message.channel.send(\":x: | You must be an administrator of this server to request a backup!\");\n        }\n        // Create the backup\n        backup.create(message.guild, {\n            jsonBeautify: true\n        }).then((backupData) =\u003e {\n            // And send informations to the backup owner\n            message.author.send(\"The backup has been created! To load it, type this command on the server of your choice: `\"+settings.prefix+\"load \"+backupData.id+\"`!\");\n            message.channel.send(\":white_check_mark: Backup successfully created. The backup ID was sent in dm!\");\n        });\n    }\n\n    if(command === \"load\"){\n        // Check member permissions\n        if(!message.member.hasPermission(\"ADMINISTRATOR\")){\n            return message.channel.send(\":x: | You must be an administrator of this server to load a backup!\");\n        }\n        let backupID = args[0];\n        if(!backupID){\n            return message.channel.send(\":x: | You must specify a valid backup ID!\");\n        }\n        // Fetching the backup to know if it exists\n        backup.fetch(backupID).then(async () =\u003e {\n            // If the backup exists, request for confirmation\n            message.channel.send(\":warning: | When the backup is loaded, all the channels, roles, etc. will be replaced! Type `-confirm` to confirm!\");\n                await message.channel.awaitMessages(m =\u003e (m.author.id === message.author.id) \u0026\u0026 (m.content === \"-confirm\"), {\n                    max: 1,\n                    time: 20000,\n                    errors: [\"time\"]\n                }).catch((err) =\u003e {\n                    // if the author of the commands does not confirm the backup loading\n                    return message.channel.send(\":x: | Time's up! Cancelled backup loading!\");\n                });\n                // When the author of the command has confirmed that he wants to load the backup on his server\n                message.author.send(\":white_check_mark: | Start loading the backup!\");\n                // Load the backup\n                backup.load(backupID, message.guild).then(() =\u003e {\n                    // When the backup is loaded, delete them from the server\n                    backup.remove(backupID);\n                }).catch((err) =\u003e {\n                    // If an error occurred\n                    return message.author.send(\":x: | Sorry, an error occurred... Please check that I have administrator permissions!\");\n                });\n        }).catch((err) =\u003e {\n            console.log(err);\n            // if the backup wasn't found\n            return message.channel.send(\":x: | No backup found for `\"+backupID+\"`!\");\n        });\n    }\n\n    if(command === \"infos\"){\n        let backupID = args[0];\n        if(!backupID){\n            return message.channel.send(\":x: | You must specify a valid backup ID!\");\n        }\n        // Fetch the backup\n        backup.fetch(backupID).then((backupInfos) =\u003e {\n            const date = new Date(backupInfos.data.createdTimestamp);\n            const yyyy = date.getFullYear().toString(), mm = (date.getMonth()+1).toString(), dd = date.getDate().toString();\n            const formatedDate = `${yyyy}/${(mm[1]?mm:\"0\"+mm[0])}/${(dd[1]?dd:\"0\"+dd[0])}`;\n            let embed = new Discord.MessageEmbed()\n                .setAuthor(\"Backup Informations\")\n                // Display the backup ID\n                .addField(\"Backup ID\", backupInfos.id, false)\n                // Displays the server from which this backup comes\n                .addField(\"Server ID\", backupInfos.data.guildID, false)\n                // Display the size (in mb) of the backup\n                .addField(\"Size\", `${backupInfos.size} kb`, false)\n                // Display when the backup was created\n                .addField(\"Created at\", formatedDate, false)\n                .setColor(\"#FF0000\");\n            message.channel.send(embed);\n        }).catch((err) =\u003e {\n            // if the backup wasn't found\n            return message.channel.send(\":x: | No backup found for `\"+backupID+\"`!\");\n        });\n    }\n\n});\n\n//Your secret token to log the bot in. (never share this to anyone!)\nclient.login(settings.token);\n```\n\n## Restored things\n\nHere are all things that can be restored with `discord-backup`:  \n\n* Server icon  \n* Server banner  \n* Server region  \n* Server splash  \n* Server verification level  \n* Server explicit content filter  \n* Server default message notifications  \n* Server embed channel  \n* Server bans (with reasons)  \n* Server emojis  \n* Server AFK (channel and timeout)  \n* Server channels (with permissions, type, nsfw, messages, etc...)  \n* Server roles (with permissions, color, etc...)\n\nExample of things that can't be restored:\n\n* Server logs  \n* Server invitations  \n* Server vanity url\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandroz2091%2Fdiscord-backup","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fandroz2091%2Fdiscord-backup","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandroz2091%2Fdiscord-backup/lists"}